Reputation: 64904
How to make a div to always appear at the top of a web page even when the paged is scrolled vertically.
Upvotes: 4
Views: 34515
Reputation: 1080
Css :
#topdiv {
position: fixed;
top: 0;
}
You can also make with JQuery,
Just always take the scrolltop value and change the div top.
$("#topdiv").css("top", scrolltop);
Upvotes: 0
Reputation: 26238
Use CSS position: fixed;
:
#topdiv {
position: fixed;
top: 0;
}
See jsFiddle example: http://jsfiddle.net/CXACT/1/
Upvotes: 10