Jump to content

Getting Position:fixed To Work Cross Browser And Dynamically


george

Recommended Posts

??? but that what position: fixed; does, what you do have to consider is the main content should use padding to place below the fixed menu, as fixed position element does not occupy any space, so the top of content will be under or overlapping the menu. The other problem is you have to use a background-color for the menu to prevent scrolling text being viewed behind it. Also position:relative; with z-index: 1; might have to be used on content container, to place it behind the menu, which should be giving a higher z-index of z-index:10; to prevent this.

Link to comment
Share on other sites

I've seen that effect in GMail. Here's how I'd implement it: With Javascript, detect the distance of the element from the top of the page and from the left of the page and save those numbers. When the scrollTop property of the window is greater or equal to the element's distance from the top of the page, then set the position to "fixed", the top to 0 and left to the distance the element is from the left of the page. Change the position back to "static" when the scrolltop property is less than the distance

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...