Forum Moderators: not2easy

Message Too Old, No Replies

z-index

Are z-index' required all the time

         

zazu

10:24 am on Jun 18, 2007 (gmt 0)

10+ Year Member



If you have div's like so:
<div id="One">
<div id="two">content</div>
<div id="three">content
<div id="four">content</div>
</div>
<div>

Is it essential to assign z-index values:

One - 0
two - 1
three - 1
four - 2

What is the effect if you don't

Thanks

vincevincevince

10:35 am on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is not important to use z-index unless you are positioning the DIVs so that two DIVs which are at the same level in the DOM are overlapping in space and you wish to specify which one should be 'on top'. Otherwise, leave them out entirely!

penders

12:33 pm on Jun 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What is the effect if you don't

Elements defined later in your source will appear on top of earlier elements (as if they had a higher z-index) if they overlap.

Just to add to what vincevincevince says, the z-index property will only have an effect if the element is positioned. ie. position:relative, position:absolute (or position:fixed?)

zazu

9:37 pm on Jun 18, 2007 (gmt 0)

10+ Year Member



Thanks

Xapti

2:36 am on Jun 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Z-indexes are not even applied to any element that is not positioned (it will be IGNORED)

It's not too often you ever have to use z-indexes on a page, since most of the time when stacking overlapping content, you just display them in the order you want them on top.