Hi,
I can't remember how to force a div to be on top of other layers, no matter where it's located code-wise.
Is that feasible?
![]()
| SitePoint Sponsor |





Hi,
I can't remember how to force a div to be on top of other layers, no matter where it's located code-wise.
Is that feasible?
![]()





z-index: 1000000000000
http://www.w3schools.com/css/pr_pos_z-index.asp





Hrmph, on second look it appears that only works with absolutely positioned elementsAnyone know how to do this with non absolutely positioned elements?

z-index:2; probably would do.
A trillion seems a little overboard to me!
Perhaps position: relative; ?Hrmph, on second look it appears that only works with absolutely positioned elements Anyone know how to do this with non absolutely positioned elements?
A few things need to be anything but the default 'static'


Only positioned elements can have a z-index applied which means that for static elements you can simply add position:relative without co-ordinates to create a local stacking context and have z-index take effect.I can't remember how to force a div to be on top of other layers, no matter where it's located code-wise.
Is that feasible?
If all elements on the page were not nested then simply setting the element you want to have the highest z-index would work.
However things are never as simple as thatIf the elements are nested then their overall level on the page will be determined by their parents z-index and not their own.
So to ensure an element remains on top then you would need to also ensure that the parent containing block's z-index is also higher than the other elements on the page.
(Note that IE does have some bugs with z-index in anything but normal situations.)
www.pmob.co.uk CSS FAQ 3 col demo Read My CSS Articles
Ultimate CSS Reference
Check out SitePoint's latest JavaScript challenge
Bookmarks