html - CSS 在较小屏幕上调整 DIV 大小

标签 html css

我的 CSS 有问题,当我调整屏幕大小时,它不会折叠,知道为什么吗?这假设位于屏幕的中心,我希望它保持在中心,但在屏幕分辨率改变时调整大小

这是我的代码:

        <div style="position:relative; width:900px; margin:auto; text-align:center; font-size:25px;">
                <div style="margin-top:70px;"> 
                    <p style="line-height:1">some textttttttttt</p>
                    <p style="line-height:1">Another texthghghghgh </p>
                    <p style="margin-top:30px">different stuff here :</p>
                    <h2 style="color:#EE3969; font-size:45px"> first</h2>
                    <h2 style="color:#DE9540; font-size:45px"> second</h2>
                    <h2 style="color:#00AAC2; font-size:45px"> third</h2>

                </div>

            </div>

谢谢

最佳答案

用此替换代码的第一行

<div style="position: relative; width: 100%; margin:auto; text-align: center; font-size: 25px;">

关于html - CSS 在较小屏幕上调整 DIV 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23571507/

相关文章:

javascript - 在 Firefox 中使用 CSS/Javascript 管理小字体可视化

javascript - 图像在 mouseenter 事件 JQuery 上不断闪烁

javascript - 为什么我不能切换汉堡菜单的显示

javascript - 自定义下拉样式

css - 如何使 div 的高度适应其中的绝对 div 的高度?

html - 转义 HTML 属性

javascript - 用纯 JS 动画最大高度?

javascript - 在内容之后加载第一部分

CSS 宽度应取决于父级

jquery - 整页滚动到特定部分