30 Seconds of CSS ⏱(atomiks.github.io)

over 3 years ago from Raul Dronca, Designer

  • Mattia AstorinoMattia Astorino, over 3 years ago

    The clearfix is an hack (not the floating) used when you use float to make a layout. In the linked project the floating is used to put divs one beside each other (as the demo shows and why i said is an obsolete way to make layouts) and this is not what it was intended for.

    Floating elements does not need any clearfix because is behavior is to be floated inside the inline content flow. Check this example of the "original" floating behavior:


    0 points
    • Thomas Michael SemmlerThomas Michael Semmler, over 3 years ago

      I didn't say that it wasn't a hack. It is, but it deals with collapsing boxes, which of course is not the only technique, but one that works consistently and that does not require another element to work. I said...

      Floating is not an obsolete technique, it was a hack because we used it for layouts. Now it can be used for what it was intended.

      Which is true. Your fiddle is showing the intended behaviour. I said, that if you want to progressively enhance your website, you might still add a clearfix because you might have a layout that still floats for the most part. Again, a clearfix is not the only solution for dealing with collapsed containers.

      The big issue is that many people don't even know why they use a clearfix, they just put it on, thinking that it must be done.

      0 points