的顶部。在我的网页我有一个div "header"
上方,下方的div "titlebar"
&它下面的其它标签。坚持股利屏幕
所以,当我滚动,我想header
&其他部分向上或向下滚动&只是titlebar
要在屏幕的顶部卡住。另外,当我向后滚动时,header
应该位于开头处的顶部& titlebar
之下。
什么是它的CSS代码?
#header{
background-color: #909090;
padding: 10px;
}
h1{
text-align: center;
color: #99ffcc;
}
#titlebar{
background-color: #101010;
width: 100%;
position: sticky;
top: 0;
}
table{
width: 100%;
}
<div id="header">
<h1>Random topic</h1>
</div>
<div id="titlebar">
<table>
<th><a href="">Home</a></th>
<th><a href="">Gallery</th>
<th><a href="">Services</th>
<th><a href="">About</th>
<th><a href="">Contact</th>
</table>
</div>
<div id="container"> <p>random posts</p></div>
你可以把一个代码示例,可以帮助。 – Bhavana
[位置固定标题在html]可能重复(http://stackoverflow.com/questions/10975268/position-fixed-header-in-html) – XYZ
可能的重复http://stackoverflow.com/questions/1216114/我怎样才能制作一个div-stick-to-the-screen-once-its-rolled-to-the-rolled-to- 这个例子展示了如何滚动div直到它位于顶部,然后粘在那里 –