[英]prevent content div from overlapping header div when scrolling
嗨,我有兩個分區。
<div id="header">
-- some random html content here --
</div>
<div id="content">
1
2
3
4
5
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
some long content that needs scrolling.
</div>
這是我的CSS。
#header {
vertical-align:middle;
position:fixed;
top:0ex;
width:800px;
height: 48px;
background-color: #FFFFFF;
z-index: 10;
}
#content {
text-align:center;
margin-left:auto;
margin-right:auto;
width: 800px;
margin-top: 24px;
}
您的問題有點令人困惑,但是我從中得到的是您需要滾動頁面的一部分並阻止頁面的一部分不滾動? 使用position:fixed代替position:absolute可以使您的div保持“此處有一些隨機html內容”,以防止其向下滾動。 要使頁眉與主體重疊,請為其指定一個值background-color:white
。 我在這里做了一個工作的例子
#header {
vertical-align:middle;
/* position:absolute; */position:fixed;
}
z-index:
top:0ex;
width:800px;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.