2011-02-01 74 views
2

IE版本是6.0时,代码是象下面这样:z索引不工作在IE

<div style="background-color: #4A840F; width:300px; height: 200px; position: relative;"> 
    <div style="background-color: #ED4100; width:200px; height: 500px; position: absolute;z-index: 100;"></div> 
</div> 
<div style="background-color: red; width:300px; height: 200px; position: relative;"></div> 

如果删除了位置=相对的第三格,一切正常,但我不能因为我需要它来修复另一个元素。但是,如果不删除它,z-index在IE中不起作用。它适用于FF和Chrome。

有人可以帮我解决吗?先谢谢你。

+0

你有没有尝试给第三个div`zoom:1`? – sdleihssirhc 2011-02-01 03:30:29

+0

只有“zoom:1”?我刚刚添加并尝试,没有任何影响。 – ywenbo 2011-02-01 03:32:44

回答

4

添加

z-index: 1; 

你的第一个div的风格。

在IE6中,偏移父级的z-index将覆盖其所有子级的z-index值。

0
<div style="background-color: #000; width:300px; height: 200px; position: relative;"> 
    <div style="background-color: blue; width:200px; height: 500px; position: absolute;z-index: 100;"></div> 
</div> 
<div style="background-color: red; width:300px; height: 200px; position: relative;z-index: -1;"></div> 

应该工作。出于好奇,你为什么支持IE6?

+0

更改为 z-index:1 – DoctorLouie 2011-02-01 03:44:37