我有一个头部的
由于某种原因,我不能在头部的底部设置边距以强制推下内容块。它完全忽略了它,我不知道为什么。
有人知道发生了什么吗?如果我取消头部的 position: fixed; 属性,则不会出现这种情况,但我希望它固定在顶部,以便滚动时始终能看到头部。
希望有人可以解释为什么会发生这种情况,或者至少告诉我它被称为什么,这样我可以搜索一下。
body {
margin: 0;
padding: 0;
font-family: arial;
background: #5A9910;
text-align: center;
}
/* ==========================Main wrap for page==*/
div.wrap {
width: 100%;
margin: 0 auto;
text-align: left;
}
/* ==========================Header with logo==*/
div.header {
position: fixed;
width: 100%;
background: #ffffff;
-webkit-box-shadow: 0 8px 6px -6px #333;
-moz-box-shadow: 0 8px 6px -6px #333;
box-shadow: 0 8px 6px -6px #333;
}
/* ==========================Header logo image==*/
img.headerlogo {
width: 30%;
}
/* ==========================Content wrapper==*/
div.contentwrap {
width: 80%;
height: 1600px;
background: #ccc;
margin: 0 auto;
}
<div class="wrap">
<div class="header">
<p>Header</p>
</div>
<div class="contentwrap">
<p>Test</p>
</div>
</div>