Previous Message
Next Message

[css-d] Mozilla handling of negative z-index values is correct according to CSS2, but not in line with Opera and IE and seems very confusing

Sent by Joshua Prowse on 17 April 2002 20:08


Re: Mozilla Bugzilla bug:
http://bugzilla.mozilla.org/show_bug.cgi?id=78087#c14

Mozilla's handling of negative z-index values is correct according to the
CSS2 spec, but it is at odds with Internet Explorer and Opera and a host of
other browsers.

This seems to be a very commonly reported bug (judging by the number of
duplicates that have been discarded).  Mozilla is apparently following the
CSS2 standard by obscuring elements with a negative z-index value by placing
them behind the <body> element.  IE and Opera are not following the standard
when they, by default, display items with negative z-index values.  But, I
can't think of any use for hiding elements that have a negative z-index
value.

Basically, when there are no background colors established for <body> or
<html>, I'd expect them to be transparent.  However, Mozilla doesn't treat
them that way: it gives them the default background color.  Therefore, any
elements that are given a negative z-index value will be obscured because
those elements are colored.

The solution is to set the <body> element to
position:relative;left:0px;top:0px;z-index:0

I don't understand this solution.  The body element is z-index:auto by
default, right?  I'm under the impression that this is supposed to inherit
the parent element's z-index value.  So, is it inheriting the <html>
element's z-index value?  If so, I thought that the z-index value of that
was auto as well.  So, what is the default?  0?

Second, why is it that when I give z-index a value of zero, then elements
that are under it appear.  But when it has the default value, then elements
that are under it don't appear.  I'd expect that if body had a z-index of
zero, then elements with a value of less than that would be obscured!
Apparently the answer has something to do with "establishing a new stacking
context."  But I don't really  understand how that works.

Help?

------------------------------------------------

Finally, do you think that Mozilla should treat this as a quirk and adopt
the other browser's (much simpler, IMO) system?  Or should Mozilla follow
the standard in this case?
Previous Message
Next Message