2011-02-01 72 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