auto,0和没有z-index之间的区别? [英] Difference between auto, 0, and no z-index?

查看:485
本文介绍了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.

这篇关于auto,0和没有z-index之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆