R
Ryan Stewart
IE 6.0 displays the following code as expected. Netscape Navigator 7.0
does not. Both get the same result up to a point. "Some other content"
is in a blue box to the left. Everything else is in a red box floated
against the blue box. "foo" clears everything above it and is at the
left border of the red box. The difference is in the three black
boxes. IE properly renders them as taking up about one third of the
red box's width apiece, each floated against the previous one. In
Netscape, however, each box's width is not even enough to contain the
letters within it. This behavior only seems to occur when nesting a
floated element within another floated element. Is this a known bug? A
feature? Is there a workaround?
Code:
<html>
<head><title>A Block</title></head>
<body>
<div style="float: left; width: 15%; border: 1px solid blue;">
<p>Some<br />other<br />content</p>
</div>
<div style="float: left; border: 1px solid red;">
<div style="width: 30%; float: left; border: 1px solid black;">
abcdef
</div>
<div style="width: 30%; float: left; border: 1px solid black;">
zyxwv
</div>
<div style="width: 30%; float: left; border: 1px solid black;">
qwerty
</div>
<p style="clear: left;">foo</p>
</div>
</body>
</html>
does not. Both get the same result up to a point. "Some other content"
is in a blue box to the left. Everything else is in a red box floated
against the blue box. "foo" clears everything above it and is at the
left border of the red box. The difference is in the three black
boxes. IE properly renders them as taking up about one third of the
red box's width apiece, each floated against the previous one. In
Netscape, however, each box's width is not even enough to contain the
letters within it. This behavior only seems to occur when nesting a
floated element within another floated element. Is this a known bug? A
feature? Is there a workaround?
Code:
<html>
<head><title>A Block</title></head>
<body>
<div style="float: left; width: 15%; border: 1px solid blue;">
<p>Some<br />other<br />content</p>
</div>
<div style="float: left; border: 1px solid red;">
<div style="width: 30%; float: left; border: 1px solid black;">
abcdef
</div>
<div style="width: 30%; float: left; border: 1px solid black;">
zyxwv
</div>
<div style="width: 30%; float: left; border: 1px solid black;">
qwerty
</div>
<p style="clear: left;">foo</p>
</div>
</body>
</html>