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

2 years ago from Raul Dronca, Designer

  • Thomas Michael SemmlerThomas Michael Semmler, 2 years ago

    If you progressively enhance your website, you might every now and then still add a clearfix, because it is only obsolete, if your browser supports display: flow-root.

    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.

    The Author of the posted content might want to add resources to the clearfix so people learn about the concepts involved in it. It is quite important to know why the clearfix is needed in many situations and what concepts are in place that make that so.


    0 points
    • Mattia AstorinoMattia Astorino, 2 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:

      https://jsfiddle.net/fceuvtu5/1/

      0 points
      • Thomas Michael SemmlerThomas Michael Semmler, 2 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