Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How does micro clearfix work?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #238132
    arnsa
    Participant

    So I found this (probably old) micro clearfix on the internet:

    .clearfix:before,
    .clearfix:after {
      content: "";
      display: table;
    }
    
    .clearfix:after {
        clear: both;
    }
    

    But I don’t understand two things. First of all, why do we need the first part (content: “” and display: table)? Why .clearfix:after { clear: both; } isn’t enough?

    Second of all, why do we specify display: table? Why display: block; doesn’t work, but display: table; does work?

    And, by the way, maybe there are even better ways to clear floats?

    #238133
    Paulie_D
    Member

    Just read the explanation: http://nicolasgallagher.com/micro-clearfix-hack/

    And, by the way, maybe there are even better ways to clear floats?

    Well yes…don’t use floats…use flexbox.

    #238139
    arnsa
    Participant

    Well, flexbox isn’t well supported by IE, do you really think it’s a good idea?

    #238140
    Paulie_D
    Member

    flexbox is fine with IE10 and up but it depends on your requirements.

    #238141
    arnsa
    Participant

    On average, what versions of IE people usually try to support?

    #238150
    Shikkediel
    Participant

    Microsoft has recently stopped supporting anything below IE11 and Edge themselves and pushing everyone to upgrade. I tend to include IE9 still though.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.