2009-12-01 40 views
4

(注意,這不是雙重保證金的錯誤,我現在稱這是雙垂直填充的bug,除非其他人有更聰明的/記錄的名稱)什麼是這個IE瀏覽器的CSS錯誤稱爲? (雙垂直填充)

就在我以爲我看過所有古怪的IE瀏覽器的CSS錯誤時,我製作了一個簡單的測試用例,它繼續讓我感到困惑。下面的頁面看起來很棒,在FF,Opera等人中效果很好。但是,IE 6和IE 7似乎感到困惑。我會讓我粘貼的文件爲自己說話。

編輯:我已經把這個在以下網址:http://jsbin.com/efele
打開它在IE瀏覽器,並再次在FF。比較。

我的問題是:這個bug叫什麼? (我是否錯過了這個地方?它是否在this page?上找到?)我熟悉3px慢跑錯誤和雙(水平)-margin錯誤以及很多其他與浮動相關的錯誤。但是......垂直填充正在重複? (並放在錯誤的地方,開機。)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>IE bork!</title> 
<style type="text/css"> 
html, body { 
margin:0; 
padding:0; 
} 
#container { 
border:1px solid red; 
background-color:#CC99CC; 
width:800px; 
margin:0 auto; 
padding-top:100px; 
} 
#sidebar { 
float:left; 
display:inline; 
width:200px; 
border:1px solid blue; 
background-color:#00CCFF; 
} 
#content { 
float:right; 
display:inline; 
width:510px; 
border:1px solid green; 
background-color:#66CC99; 
} 
.clear { 
clear:both; 
/* height:0px; <<< setting height seems to be the only thing that makes this work as expected?!? */ 
background-color:#CCCCCC; /* bg color here is just for debugging */ 
} 
</style> 
</head> 
<body> 
<div id="container"> 
    <div id="sidebar">I am the sidebar</div> 
    <div id="content">I am the content</div> 
    <div class="clear"><!-- clear! --></div> 
</div> 
<p>There should be 100px of space above the two floats, but <em>no</em> space below them...</p> 
</body> 
</html> 

P.S.,我終於弄清楚如何安撫IE瀏覽器了。解決方案(明確地在我的「清除」div上設置高度)被註釋掉以顯示錯誤。我只希望我能回到生命中的最後幾個小時,這讓我偶然發現真正的問題/解決方案!

謝謝!

回答

3

鑑於您找到的解決方案,它似乎是hasLayout IE quirk。

+0

我希望有一個有趣/聰明的名字,例如那些在你鏈接的網站上;我想我得解決一些無聊的事情! – Funka 2009-12-08 23:31:02

2

在一個側面說明(明確設置你的明確DIV高度在IE心目中樹立hasLayouttrue),在指定高度不會出於某種原因的情況下,我經常發現,包括任何時候我需要hasLayout在IE中觸發一直是救生員。任何時候,在IE中我都有這些奇怪的佈局問題,我總是試着去看看它是否是一個佈局刷新問題。 (然後,如果這不起作用,繼續對着鍵盤敲頭)

+0

謝謝。我也喜歡這種方式! – Funka 2009-12-08 23:31:38