I want to add a always-on-top header like the new twitter does. Explanation: When the user scrolls down the page, I want the header to stay on top of the window.
Somebody know a script that does that? Or can target me how can I do it?
I want to add a always-on-top header like the new twitter does. Explanation: When the user scrolls down the page, I want the header to stay on top of the window.
Somebody know a script that does that? Or can target me how can I do it?
Share Improve this question asked Dec 7, 2010 at 10:12 ChiefChief 231 silver badge3 bronze badges3 Answers
Reset to default 5You can use position: fixed; on the header.
<div id="header">
content goes here.
</div>
and the CSS:
#header { position: fixed; z-index: 9999; top: 0; left: 0; }
You need to give your header a position of fixed
to make it visible throughout the page. And set the top
value appropriately along with width
.
Example:
#header{
position:'fixed';
top:0;
width:800px;
}
Use position:fixed
on the header in its CSS.
Also, dont forget to set the left
and top
attributes to where you want it to go :)