Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 921
  • Last Modified:

CSS - stationary div at the top of the page while the rest of the page scrolls.

I'm building a page that will have a navigation bar that spans the top of the page.  The page will be 1024px wide, centered in the browser window and there is a background image that will show on both sides of the page for windows that show more than 1024px in width.  I want the navigation bar to remain at the top of the browser window regardless of scrolling the page up and down.  What needs to be done with the CSS for this to work?
0
josephdaviskcrm
Asked:
josephdaviskcrm
  • 2
  • 2
1 Solution
 
nexusnationCommented:
position:fixed; top: 0;

That little bit of CSS will rest a block-level element at the very top of your page.

For more, see:
http://www.w3schools.com/css/pr_class_position.asp
0
 
josephdaviskcrmAuthor Commented:
Sorry it took so long to get back to this one.

Ok... this works great in everything but IE6 (wonder of wonders).  What needs to be done for it to work the same?
0
 
nexusnationCommented:
Not a problem..
IE 6 doesn't support position:fixed, so you'd have to use some sort of a hack. There are various ways to do this, but I have never needed to try this, so the best thing would be to Google "position fixed IE 6".

Here's what I came up with that looked somewhat promising:

http://web.tampabay.rr.com/bmerkey/examples/fake-position-fixed.html
http://www.howtocreate.co.uk/fixedPosition.html
http://tagsoup.com/cookbook/css/fixed/
0
 
josephdaviskcrmAuthor Commented:
Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now