简体   繁体   English

绝对元素不与固定位置div重叠

[英]Absolute element doesn't overlap fixed position div

I have layout with two fixed positioned div's(Class A and Class B). 我有两个固定位置的div(A类和B类)的布局。 Also i have a absolute positioned div(Class C) inside class B with z-index greater than class A. In chrome class C doesn't overlap class A. It is working fine in Firefox. 我也有绝对定位div(Class C)在类B中,其z-index大于类A。在chrome类C中不与类A重叠。它在Firefox中运行良好。

HTML 的HTML

<div class="A"></div>
<div class="B">
    <div class="C"></div>
</div>

CSS 的CSS

.A{position:fixed; width:200px; height:50px; z-index:1; background-color:#FCC}
.B{ position:fixed}
.C{position:absolute; z-index:2; top:-10px; background-color:#CC6; width:70px; height:50px;}

Jsfiddle 杰斯菲德尔

Note: Adding z-index to class B might solve the problem, but in my case i cannot do that. 注意:向类B添加z-index可能会解决此问题,但就我而言,我无法做到这一点。 Is there any other way to fix it? 还有其他解决方法吗?

.A上设置z-index:0 ,它将在顶部移动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM