Solution (Clean Markup Solution)
Date of the Solution
Tue Aug 18 21:17:26 2009
Fixed Versions
All of the affected
Description
Fixed demo is available on a separate page
- HTML Code:
<div>
Here is a <div> having float: left and clear: left. As expected,
it takes, it occupies as much width it requires from the body's content
area.
</div>
<span class="ie_fix"></span>
<div>
This is the same type of <div>: a left-floated <div> with
clear: left. This <div> should use, should take, should occupy
the whole content area of the body node (expected results). However, in
Internet Explorer 7, this left-floated <div> with clear: left only
takes, only occupies a very narrow chunk of the body's content area
(actual results). More text filling. More text filling. More text
filling. More text filling. More text filling.
</div>
<span class="ie_fix"></span>
<div>
Here, a third <div> having float: left and clear: left. Change
your browser window viewport's width.
</div>
<ul>
<li>
<div>Here is a <div> having float: left and clear: left. As expected,
it takes, it occupies as much width it requires from the body's content
area.</div>
</li>
<li>
<div>This is the same type of <div>: a left-floated <div> with
clear: left. This <div> should use, should take, should occupy
the whole content area of the body node (expected results). However, in
Internet Explorer 7, this left-floated <div> with clear: left only
takes, only occupies a very narrow chunk of the body's content area
(actual results). More text filling. More text filling. More text
filling. More text filling. More text filling.</div>
</li>
<li>
<div>Here, a third <div> having float: left and clear: left. Change
your browser window viewport's width.</div>
</li>
</ul>
- CSS Code:
div {
background-color: #ddd;
border: 1px solid green;
clear: left;
color: black;
float: left;
}
.ie_fix { display: inline-block; }
.ie_fix { display: block; }
Let's see what I am doing here. In the ' element"><div>
part of the demo, I am inserting an extra ' element"><span>
element between each ' element"><div>
and giving that ' element"><span>
"layout" (with {display: inline-block;}
) as well as setting its display
to value block
.
Since we cannot insert that ' element"><span>
element between our ' element"><li>
elements; what I am doing in the ' element"><ul>
part of the demo is wrapping the contents of each ' element"><li>
in a separate ' element"><div>
and floating that ' element"><div>
instead (note that I've removed the float off the ' element"><li>
s).
Even though this solution is not perfect, as the fixed shrink-wrap would not completely interract with surrounding elements the same way as the original demo would in sane browsers, this method of fixing the bug may be your lucky ticket.