【发布时间】:2009-08-31 15:58:52
【问题描述】:
在下面的代码中,我有 2 个 div,每个都有两个嵌套的 div。当浏览器窗口在 Firefox/IE8 下重新调整大小时,一切正常 - 最右边的父 div 落在第一个下面。
在 IE6(或兼容模式的 IE8)下,子 div 在第二个 div 包装中。更糟糕的是,尽管我为 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 不支持最大高度,一方面
-
即使“身高”有效,我也会很高兴。
标签: css internet-explorer html