Tests
Test 0
order in HTML source
- AP Box only
<div class="relative">
<div class="ap_box"></div>
</div>
result
- IE6
- IE7
Test 1
order in HTML source
- AP Box
- float
- clear + hasLayout
<div class="relative">
<div class="ap_box"></div>
<div class="float"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 1b - Solution#1 for Test 1
Use the clear without the hasLayout propety.
order in HTML source
- AP Box
- float
- clear
<div class="relative">
<div class="ap_box"></div>
<div class="float"></div>
<div class="clear"></div>
</div>
result
- IE6
- IE7
Test 1c - Solution#2 for Test 1
Put an extra box between the AP Box and the float.
order in HTML source
- AP Box
- extra box
- float
- clear hasLayout
<div class="relative">
<div class="ap_box"></div>
<div class="extra">extra box</div>
<div class="float"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
footnote
It's all right if the extra box is empty (<div class="extra"></div>).
Test 1d - Solution#3 for Test 1
Wrap the AP Box with an extra box.
order in HTML source
- <extra box>AP Box</extra box>
- float
- clear hasLayout
<div class="relative">
<div class="extra"><div class="ap_box"></div></div>
<div class="float"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 1e - Solution#4 for Test 1
Wrap the float with an extra box.
order in HTML source
- AP Box
- <extra box>float</extra box>
- clear + hasLayout
<div class="relative">
<div class="ap_box"></div>
<div class="extra"><div class="float"></div></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 1f - Solution#5 for Test 1
Put the extra box after the AP Box and the float.
order in HTML source
- AP Box
- float
- extra box
- clear hasLayout
<div class="relative">
<div class="ap_box"></div>
<div class="float"></div>
<div class="extra">extra box</div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 1g
It's not OK if you put the extra box before both the AP Box and the float.
order in HTML source
- extra box
- AP Box
- float
- clear hasLayout
<div class="relative">
<div class="extra">extra box</div>
<div class="ap_box"></div>
<div class="float"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 2
order in HTML source
- float
- AP Box
- clear + hasLayout
<div class="relative">
<div class="float"></div>
<div class="ap_box"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 2b - Solution#1 for Test 2
Use the clear without the hasLayout propety.
order in HTML source
- float
- AP Box
- clear
<div class="relative">
<div class="float"></div>
<div class="ap_box"></div>
<div class="clear"></div>
</div>
result
- IE6
- IE7
Test 2c - Solution#2 for Test 2
Put an extra box between the float and the AP Box.
order in HTML source
- float
- extra box
- AP Box
- clear + hasLayout
<div class="relative">
<div class="float"></div>
<div class="extra">extra box</div>
<div class="ap_box"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
footnote
It's all right if the extra box is empty (<div class="extra"></div>).
Test 2d - Solution#3 for Test 2
Wrap the AP Box with an extra box.
order in HTML source
- float
- <extra box>AP Box</extra box>
- clear hasLayout
<div class="relative">
<div class="float"></div>
<div class="extra"><div class="ap_box"></div></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 2e - Solution#4 for Test 2
Wrap the float with an extra box.
order in HTML source
- <extra box>float</extra box>
- AP Box
- clear + hasLayout
<div class="relative">
<div class="extra"><div class="float"></div></div>
<div class="ap_box"></div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 2f - Solution#4 for Test 2
Put the extra box after the float and the AP Box.
order in HTML source
- float
- AP Box
- extra box
- clear + hasLayout
<div class="relative">
<div class="extra"><div class="float"></div></div>
<div class="ap_box"></div>
<div class="extra">extra box</div>
<div class="clear hasLayout"></div>
</div>
result
- IE6
- IE7
Test 3
order in HTML source
- float
- clear + hasLayout
- AP Box
<div class="relative">
<div class="float"></div>
<div class="clear hasLayout"></div>
<div class="ap_box"></div>
</div>
result
- IE6
- IE7
Test 4
order in HTML source
- AP Box
- float (float's width < container's width)
<div class="relative">
<div class="ap_box"></div>
<div class="float"></div>
</div>
result
- IE6
- IE7
Test 4a
order in HTML source
- AP Box
- float + width:100%
<div class="relative">
<div class="ap_box"></div>
<div class="float w100"></div>
</div>
result
- IE6
- IE7
Test 4b - Solution#1 for Test 4a
Give a negative margin (at least -2px) to the float.
order in HTML source
- AP Box
- float + width:100% + margin-right:-2px
<div class="relative">
<div class="ap_box"></div>
<div class="float w100 negm"></div>
</div>
result
- IE6
- IE7
footnote
-1px is not sufficient to fix the problem. (See Test 4d.) But -2px is not still enough if display:inline is used on the float. (See Test 4e.)
Test 4c - Solution#2 for Test 4a
Put an extra box between the float and the AP Box.
order in HTML source
- AP Box
- extra box
- float + width:100%
<div class="relative">
<div class="ap_box"></div>
<div class="extra">extra box</div>
<div class="float w100"></div>
</div>
result
- IE6
- IE7
footnote
It's OK if the extra box is empty (<div class="extra"></div>). And it's also all right if the extra box wraps the AP Box or the float like Test 1d and Test 1e.
Test 4d (additional test for Test 4b)
A negative margin -1px is not sufficient to fix the problem.
order in HTML source
- AP Box
- float + width:100% + margin-right:-1px
<div class="relative">
<div class="ap_box"></div>
<div class="float w100" style="margin-right: -1px;"></div>
</div>
result
- IE6
- IE7
Test 4e (additional test for Test 4b)
If you apply display:inline to the float, -2px is not enough.
order in HTML source
- AP Box
- float + width:100% + margin-right:-2px + display:inline
<div class="relative">
<div class="ap_box"></div>
<div class="float w100" style="margin-right:-2px; display:inline;"></div>
</div>
result
- IE6
- IE7
Test 4f (additional test for Test 4b)
A positive margin can't resolve the problem.
order in HTML source
- AP Box
- float + width:100% + margin-right:1px
<div class="relative">
<div class="ap_box"></div>
<div class="float w100" style="margin-right: 1px;"></div>
</div>
result
- IE6
- IE7
Test 5
order in HTML source
- float
- AP Box
<div class="relative">
<div class="float"></div>
<div class="ap_box"></div>
</div>
result
- IE6
- IE7
Test 5a
order in HTML source
- float + width:100%
- AP Box
<div class="relative">
<div class="float w100"></div>
<div class="ap_box"></div>
</div>
result
- IE6
- IE7
Test 5b - Solution#1 for Test 5a
Same as Test 4b.
order in HTML source
- float + width:100% + margin-right:-2px
- AP Box
<div class="relative">
<div class="float w100 negm"></div>
<div class="ap_box"></div>
</div>
result
- IE6
- IE7
Test 5c - Solution#2 for Test 5a
Same as Test 4c.
order in HTML source
- float + width:100%
- extra box
- AP Box
<div class="relative">
<div class="float w100"></div>
<div class="extra">extra box</div>
<div class="ap_box"></div>
</div>
result
- IE6
- IE7