Which method of 'clearfix' is best?

Posted by Pickledegg on Stack Overflow See other posts from Stack Overflow or by Pickledegg
Published on 2008-10-17T08:15:36Z Indexed on 2010/05/26 3:21 UTC
Read the original article Hit count: 211

Filed under:

I have the age old problem of a div wrapping a 2 column layout. My sidebar is floated so my container div fails to wrap the content & sidebar.

<div id="container">
  <div id="content">
  </div>
  <div id="sidebar">
  </div>
</div>

There seem to be numerous methods of fixing the clear bug in FF:

<br clear="all"/>
overflow:auto
overflow:hidden

etc.

But in my situation, the only one that seems to work correctly is the <br clear="all"/> solution, which is a little bit scruffy. overflow:auto gives me nasty scrollbars, and overflow:hidden must surely have side effects. Also, apparently IE7 is supposed to not suffer from this problem due to its incorrect behaviour, but again, in my situation its suffering the same as FF.

Whats the most reliable/best practice method currently available to us?

© Stack Overflow or respective owner

Related posts about css