Re: breaking overflow

Brad Kemper wrote:
> On Dec 30, 2009, at 6:49 PM, James Hopkins wrote:
> 
>> One alternative is to generate clearing content using the :after pseudo element but this seems like a blatant hack, and I don't believe authors should have to be reliant on utilizing :after for the sole purpose of clearing floats.
> 
> I don't think it is any worse that relying on a side effect of overflow settings. In fact, I think that creating a presentaional effect of a separate markup element without having the actual element present in the markup is a perfectly valid and important use case for ':after' (or with the ':before' example I posted earlier).
> 

I second this.  I admit that I am a strong proponent of this "clearfix"
technique, but I have never understood why people find it quite so
distasteful since it merely exploits the correct, intended behaviour of
several CSS concepts to achieve the desired effect.

I find that, when pressed, most people admit that their dislike of the
technique stems primarily from the size and complexity of the CSS
declaration block than from any conceptual objection.  Certainly, many
people still associate the clearfix technique with a load of
browser-specific cruft for now-obsolete UAs.  In its cleanest
incarnation, which works in all modern (and even not-so-modern)
browsers, the technique is merely the following:

div:after {
	content: "";
	display: block;
	clear: both;
}

(and additionally giving the div hasLayout for IE6/7).


Which is not to say that I don't think there's a place for simple
property/value to achieve the same effect....

Cheers,
Anton Prowse
http://dev.moonhenge.net

Received on Thursday, 31 December 2009 09:39:02 UTC