auto,0和没有z-index之间的区别?

auto,0和没有z-index之间的区别?

问题描述:

有什么区别:

What is the difference between:


  1. z-index:auto

  2. z-index :0

  3. 完全没有z索引

以上所有情况均适用于div包含两个div,div1和div2,每个div的索引分别为9和10.

all the above scenarios are for a div that encloses two divs, div1 and div2 each having a z index which is 9 and 10 respectively.

封闭div位于html的堆叠环境中。

The enclosing div is in the stacking context of html.

不指定 z-index z-index相同:auto ;这是它的初始值。

Not specifying z-index is the same as z-index: auto; that is its initial value.

auto 0 如果你的元素没有创建自己的堆栈上下文,这意味着同样的事情;例如它不是相对的,绝对的或固定的。

auto and 0 mean the same thing if your element doesn't create its own stacking context; e.g. it is not positioned as relative, absolute or fixed.

如果您的封闭 div 未定位,你将它的 z-index 设置为无关紧要;它及其所有内容将参与 html 的堆叠环境,并且其后代将始终位于其前面。

If your enclosing div isn't positioned, then whatever you set its z-index to doesn't matter; it and all its contents will participate in the stacking context of html, and its descendants will always be positioned in front of it.