How do I make a DIV stay at the top of the screen no matter ow far down the page my visitor scrolls?

Posted by user1289863 on Stack Overflow See other posts from Stack Overflow or by user1289863
Published on 2012-03-24T11:22:13Z Indexed on 2012/03/24 11:29 UTC
Read the original article Hit count: 138

Filed under:
|
|

What I'm saying is, I have some extremely long pages on my website, which can make it annoying I've my visitors need to scroll to the top of the page to be able to navigate to another page.

I'm not quite sure what I would call this but any Google search that contains the words 'DIV' and 'float' come up with completely unrelated results...

What I'm looking to do is create a DIV that stays at the top of the Screen (not to be confused with the page) so that if the user is at the bottom of the page, they can still see the navigation bar just floating at the top of the screen. What I can think of is to position the DIV relative to the position of the screen but I don't know how to code this.

I'm happy to use JavaScript (preferably in the form of jQuery), but if you know how to do this using CSS, I would favour your response.

This might help: I know a little bit of jQuery and JavaScript and I know a good deal of CSS and HTML.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about css