我想制作一个带有一些菜单链接的页眉。内部 div 没有占用 距顶部的边距。请建议我如何为此编写 css。
<div style ="width:100%; background-color:Aqua; height:100px;">
<div style="width:876px;background-color:Blue;margin:20px auto;height:60px;">
<h3>menu items</h3>
</div>
</div>
另外,当我调整浏览器大小时(在 mozilla 上按 shift+ctrl+M),外部 div 没有正确包裹内部 div。
最佳答案
你可能会得到这个,因为你的第二个宽度是固定的,所以无论浏览器大小,它永远不会改变,而第一个宽度会改变,因为它是百分比
<div style ="width:100%; background-color:Aqua; height:100px;">
<div style="width:70%;background-color:Blue;margin:20px auto;height:60px;">
<h3>menu items</h3>
</div>
</div>
关于html - 无法正确定位页眉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27902109/