Jump to content

Clearfix?


davej

Recommended Posts

So is "Clearfix" just an arbitrary name used to describe the use of the pseudo :after selector to clear floats -- or it is meant to be a "Clear" combined with a "Fix" for certain browsers bugs?

 

This guy calls his version a "hack"...

 

http://nicolasgallagher.com/micro-clearfix-hack/

 

http://www.w3schools.com/cssref/sel_after.asp

 

Link to comment
Share on other sites

Clearfix just meant creating an element with "clear: both" in order to make a container surround floated elements. It doesn't necessarily require using the :after selector though that does prevent having to create extra elements in the document. The :after selector does not work in Internet Explorer 7 and under, so I suppose his hack is meant to address that.

 

The overflow method is better than a clearfix, but for old versions of Internet Explorer and Opera you needed to set a specific width to the element which is why it wasn't used as much back then. Today I don't see any reason to use "clearfix".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...