在下面的代碼中我有2個div,每個div有兩個嵌套的div。當瀏覽器窗口在Firefox/IE8下重新調整大小時,它一切正常 - 最右邊的父div落在第一個下面。防止嵌套DIV包裹(不指定父寬度)
但是,在IE6下(或具有兼容模式的IE8)第二個div換行中的子div。更糟糕的是,這發生了DESPITE事實,我已經爲div設置了最大高度。
在這種情況下,如何讓IE6的行爲像IE8/Firefox?我如何告訴DIV不要包裝?請注意,文字是動態的,因此我無法將寬度設置爲父級。
<!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 runat="server">
<title></title>
<style type="text/css">
.parent
{
float: left;
border: solid 1px black;
height: 30px;
white-space: nowrap;
}
.child
{
float: left;
border: solid 1px grey;
width: auto;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="parent">
<div class="child">
What is up, guy What is up, guy
</div>
<div class="child">
What is up, guy What is up, guy
</div>
</div>
<div class="parent">
<div class="child">
What is up, guy What is up, guy
</div>
<div class="child">
What is up, guy What is up, guy
</div>
</div>
</form>
</body>
</html>
IE6不支持最大高度,一件事 – 2009-08-31 16:01:37
即使只有「高度」工作,我也會很開心。 – VitalyB 2009-08-31 16:36:40