2010-09-09 75 views
0

它適用於所有其他瀏覽器(我認爲)。爲什麼粉色盒子在IE6中不重疊?

http://www.webdevout.net/test?01H&raw

代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html lang="en"> 
    <head> 
    <title>Test</title> 
    <style type="text/css"> 
* { overflow: visible; } 
#precedence { float: right; height: 60px; width: 50px; background: pink; margin-bottom: -10px; margin-right: 20px; overflow: visible; } 
#first { height: 50px; border: 1px dashed blue; background: white; margin-bottom: -10px; z-index: 100; position: relative; overflow: visible; } 
#second { height: 50px; border: 1px dashed red; background: white; z-index: -1; overflow: visible; } 
    </style> 
    </head> 
    <body> 
    <div id="first"> 
     <div id="precedence"></div> 
    </div> 
    <div id="second"></div> 
    </body> 
</html> 

回答

1

添加position: relative;到箱(#precedence)。這將迫使IE把它放在它所做的分層計算中。然後它會意識到它不包含在它的父項(#first)中並且會正確地溢出。

這是測試的例子:http://jsfiddle.net/s4W52/

它工作在IE6,IE7,IE8,火狐2.0.x版本/ 3.0.x的,所以應該在其他工作太