views:

451

answers:

3

In the code below I have 2 divs, each having two nested divs. When the browser window is re-sized under Firefox/IE8 it all works well - The rightmost parent div falls down under the first one.

Under IE6, however (or IE8 with compatibility mode) the child divs in the second div wrap. To make things worse, it happens DESPITE the fact I've set a max-height to the div.

How do I make IE6 behave like IE8/Firefox in this case? How can I tell the DIVs not to wrap? Note that the text is dynamic so I can't set width to the parent.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<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>
A: 

You could use conditional comments to get IE to use height, and use max-height everywhere else.

<link rel="stylesheet" type="text/css" href="path/to/stylesheet" />

<!--[if IE 6]>
<style type="text/css">
.parent {
  height: 30px;
}
</style>
<![endif]-->
Evan Meagher
It doesn't work. Even if I just put 'height' in it (without condition), it still ignores the height.
VitalyB
A: 

Why don't you specify the width in percentage? That should make it expand and shrink like you want without wrapping.

idrumgood
I'm unable to specify percentage since in my layout there is unknown number of parent boxes and I don't know neither they relative nor fixed width. It would solve the issue however.
VitalyB
A: 

I had that question answered on DocType:

http://doctype.com/preventing-nested-divs-wrap-without-specifying-parent-width

Thanks.

VitalyB