Previous Message
Next Message

Float 100% width, do I need clear:both?

Sent by Micky Hulse on 15 July 2012 20:08


Hi David and Georg, many thanks for you replies and help, I really
appreciate the pro assistance. :)

> A clickable link to the specific page in question to the list  is
> always to  your advantage. Or, is it?

Doh! Sorry about that. I actually do have a demo page, but for some
reason I didn't post a link to it.

"Clearing floats in IE 7 and below..."
<http://jsbin.com/odoreq>

A few interesting things to note:

1.

In IE7 (and probably below, I did not check IE6), when the floats were
not contained by a parent div, I got about 50px of a gap between top
and bottom floats. I eventually found this helpful page:

<http://www.brunildo.org/test/IEFloatClearPadding.html>

... which describes the problem; I needed a container div. I had never
run into this bug before - then again, I normally have containers
around my floats (If it was not for putting together a simple demo
page, I probably would have never discovered this interesting bug.)

2.

At one point, this bit of info helped:

"IE 7 clear:both not working"
<http://www.keyboardface.com/archives/2010/03/16/ie-7-clearboth-not-working/comment-page-1/>

... but it felt like more of a mysterious hack than an actual fix.

3.

Interestingly enough, IIRC, if #stuff <div> has "clear:both", and
there's a "float:right" preceding it, then everything works great...
"clear:both" fails if the the float above is floated right.

I think this page describes the problem:

<http://www.brunildo.org/test/IEWfc3.html>

"A float having the clear property (value both) only clears preceding
floats of its same direction (left/right.)"

... Now, that's good to know. :D

-----

Thanks for the tips Georg! So you're saying:

#stuff {
	/* ... */
	clear: both; /* Causes bugs in IE < 8. */
	*clear: none;
}

(I know, it's a hack... For the sake of demo, I hope ya'll don't mind.)

The above sounds good to me! In fact, I think my gut was telling me to
do this at one point, but in every browser I tested (sans IE < 8) not
having "clear:both" worked, so I figured it was superfluous (in this
test case, that is). On the other hand, having "clear:both" don't hurt
none, so what the heck, right? :D

Thanks again folks! I really appreciate the help!

Cheers,
Micky
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: