大佬教程收集整理的这篇文章主要介绍了css – z-index chrome bug,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
HTML:
<div id="mask"> </div> <div id="box"> <div class="below-mask circle"> should be below the mask </div> <div class="above-mask circle"> should be above the mask </div> </div>
CSS:
body { font-family: Verdana; font-size: 9px; margin: 0px; } #box { position: fixed; } #mask { position: absolute; left: 0px; top: 0px; BACkground-color: rgba(0,0.5); width: 100%; height: 100%; z-index: 9998; } .circle { position: relative; BACkground-color: rgba(255,204,0.75); border-radius: 75px; line-height: 150px; margin: 50px; text-align: center; width: 150px; height: 150px; } .above-mask { z-index: 9999; } .below-mask { z-index: 9997; }
沙箱:http://jsfiddle.net/gibatronic/umbgp/
我在OS X和Windows上的Internet Explorer 9,Firefox 15,Opera 12.02和Safari 5.1.7上进行了测试,所有这些都按预期显示.
我还在Ubuntu 12.10上进行了测试,它适用于包括Chrome在内的所有浏览器!
我甚至在Kindle 4浏览器上测试过它的功能!
我想知道是否有人知道解决这个问题的任何修复方法!
position: fixed
always creates a new stacking context,even when z-index
is auto
.所以堆叠上下文层次结构如下所示:
>文档根(z-index 0)
> #mask(z-index 9998)
> #box(z-index 0)
> .above-mask(z-index 9999)
> .below-mask(z-index 9997)
这意味着9998永远不会与9999或9997进行比较来确定堆叠顺序.相反,将9999与9997进行比较以确定.above-mask和.below-mask中的哪一个位于前面,然后一旦#box内的所有内容都堆叠在该上下文中,它将被视为z-index 0处的单个层.在z-index 9998处被堆叠在#mask后面.
这也解释了为什么@ TheNextBillGates在#box内移动#mask的答案 – 因为#mask与.above-mask和.below-mask处于相同的堆叠上下文中.我强烈推荐以上链接以获取更@R_772_11279@详细信息,您还应该看到the announcement for the stacking change for fixed
elements in Chrome.
以上是大佬教程为你收集整理的css – z-index chrome bug全部内容,希望文章能够帮你解决css – z-index chrome bug所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。