我有两个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;
}
为什么标题会下降,即使我在容器上放了一个保证金?有人可以建议我像其他常用页面一样在容器中有一个固定的标题和其他东西吗?
答案 0 :(得分:1)
尝试在标头css中使用top:0
。 http://jsfiddle.net/Nh3Tf/
答案 1 :(得分:1)
您需要添加top:0;
和left: 0;
.header{
width:100%;
height:100px;
position:fixed;
background-color:#eee;
top: 0;
left: 0;
}
看看here