html - 无法正确定位页眉

标签 html css

我想制作一个带有一些菜单链接的页眉。内部 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/

相关文章:

php - 如何创建 A4 页面大小的打印 View 并修复每页的边框

javascript - 所需文件上传进度条

javascript - 如何计算调整窗口大小的div背景图像大小

html - 基础CSS在列之间添加垂直线

javascript - 在 JavaScript 中使用 createElement,如何在 <div> 中添加 <p> 和 <span>?

javascript - 将 CSS A 类复制到 B 类

html - -webkit-filter 在单个 div VS 多个 div 上的性能

php - Jquery 中的进度条无法正常工作

HTML DIV 没有水平对齐

html - 我希望我的 3 block 背景在 asp.net 中保持静止