简体   繁体   中英

Absolute element doesn't overlap fixed position div

I have layout with two fixed positioned div's(Class A and Class 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.

HTML

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

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. Is there any other way to fix it?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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