Skip to content

Clearfix change from v3 should be listed under breaking changes #24973

Closed

Description

@geoffbeaumont

Bootstrap clearfix has only an :after, the :before pseudo element has been dropped. Not sure why as the old version was far more useful (contains top margins within the element), and I can't think of an instance where the new version would be better.

More to the point, however - this will break a lot of existing layouts, so needs to be listed under breaking changes (or the :before restored, which would be my preference).

Activity

  1. davidsneighbour commented on Dec 10, 2017

    @davidsneighbour

    As far as I understand this might be in line with the new mantra of avoiding margin-top:

    Avoid margin-top. Vertical margins can collapse, yielding unexpected results. More importantly though, a single direction of margin is a simpler mental model.

    see here

  2. mdo commented on Dec 11, 2017

    @mdo
    Member

    Are you referring to the move from v3 to v4?

    Not related to the margin approach.

  3. geoffbeaumont commented on Dec 15, 2017

    @geoffbeaumont
    Author

    @mdo - Sorry, yes - the version of clearfix in v4 is much less useful than the one in v3, and will break existing layouts if they are upgraded to v4.

    @pkollitsch - while I agree with the general principle of consistently using bottom margins in preference to top, there are legitimate reasons for using top margins - for example an offset from the top of a container to align the element with another element. Or (though this is less likely to be affected by clearfix), ensuring a suitable space above a block when you don't know what will precede it (common when assembling a page from blocks in a CMS) - i.e. some blocks visually require wider spacing than others, so you can't use just bottom margins as the space to the next block may differ depending what the next block is. It's a good guideline but not an unbreakable law.

  4. Kout commented on Dec 20, 2017

    @Kout
    Contributor

    @geoffbeaumont Isn’t dropping :before related to dropping old IEs support? Modern browsers require just single ::after to clearfix correctly. See http://cssmojo.com/the-very-latest-clearfix-reloaded/.

  5. geoffbeaumont commented on Dec 20, 2017

    @geoffbeaumont
    Author

    @Kout It is - it was there to maintain consistency as applying zoom:1 in old IE browsers caused them to wrap around contained margins (no collapsing of overlapping margins), so clearfix had to have that behaviour in old IE, and it was better that it did the same in newer browsers.

    There's a strong case for separating clearfix and a mixin/utility class for creating a block-formatting context (wrapping margins/preventing margin collapse) - yes, I have just changed my mind about that - but this remains a breaking change which should be documented.

  6. Kout commented on Dec 20, 2017

    @Kout
    Contributor

    @geoffbeaumont I see, and agree, it’s a breaking change.

    BTW There’s good read on the topic of block formatting context, by Rachel Andrew

  7. added a commit that references this issue on Dec 30, 2017
    ea1c866
  8. geoffbeaumont commented on Jan 2, 2018

    @geoffbeaumont
    Author

    I don't agree that this issue has been closed by the addition to the migration page. This reads simply:

    "Clearfix updated to drop support for older browser versions."

    which indicates only that the clearfix included will no longer support older browser versions, not that the behaviour of clearfix has changed in the browsers which are supported, which given that the older browsers are no longer supported by bootstrap as a whole is rather more pertinent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions