Previous Message
Next Message

Why z-index does not work for transformed element?

Sent by Philippe Wittenbergh on 8 January 2012 05:05


On Jan 8, 2012, at 1:47 PM, Peng Yu wrote:

> In the following example, no matter what z-index I set, div2 is always
> above the first div. Does anybody know how to change css to make div2
> in the bottom? Why z-index does not work with transform?

In general, z-index only applies to positioned elements as already noted.
http://www.w3.org/TR/CSS21/visuren.html#propdef-z-index

However, transformed() elements establish their own stacking context, and z-index _should_ apply
even if the element is not positioned.

http://www.w3.org/TR/css3-2d-transforms/#introduction
> Any value other than ‘none’ for the transform results in the creation of both a stacking context
and a containing block. The object acts as a containing block for fixed positioned descendants.

The text does not yet mention z-index… it was agreed within the CSS WG, however.
http://lists.w3.org/Archives/Public/www-style/2011Apr/thread.html#msg116

BTW - a positive z-index will move your element higher in the stacking order, if you want it below
(under), try a negative z-index.

Philippe
--
Philippe Wittenbergh
http://l-c-n.com/






______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: