我有两个 div。
<div class="header"></div>
<div class="container">
<p>This is the container.</p>
</div>
这是CSS代码。
.header{
width:100%;
height:100px;
position:fixed;
background-color:#eee;
}
.container{
margin:0 auto;
margin-top:100px;
margin-bottom:100px;
}
为什么标题会下降,即使我在容器上放置了边距顶部?有人可以建议我有一个固定的标题以及容器中的其他内容,就像任何其他常用页面一样吗?
最佳答案
尝试在标题 css 中使用 top:0
。 http://jsfiddle.net/Nh3Tf/
关于html - 如何根据另一个 div 的边距定位一个 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23435370/