查看此评论 from jquery-ui
// Ignore z-index if position is set to a value where z-index is ignored by the browser
// This makes behavior of this function consistent across browsers
// WebKit always returns auto if the element is positioned
我看到如果元素是 position: static
,jquery 的 zIndex()
返回 0。
position:static 不支持 z-index 吗? (它在 Chrome 中对我有用,还没有测试过跨浏览器)
最佳答案
因为position: static
的意思是“忽略所有从left
,top
,z-index
开始的定位指令等等。”
'z-index'
Value: auto | <integer> | inherit
Initial: auto
Applies to: positioned elements
— http://www.w3.org/TR/CSS21/visuren.html#z-index
An element is said to be positioned if its 'position' property has a value other than 'static'.
— http://www.w3.org/TR/CSS21/visuren.html#positioned-element
关于jquery - 为什么 z-index 被位置 :static? 忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8486475/