You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clearfix change from v3 should be listed under breaking changes #24973
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).
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.
@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.
@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.
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.
Activity
davidsneighbour commentedon Dec 10, 2017
As far as I understand this might be in line with the new mantra of avoiding margin-top:
see here
mdo commentedon Dec 11, 2017
Are you referring to the move from v3 to v4?
Not related to the margin approach.
geoffbeaumont commentedon Dec 15, 2017
@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.
Kout commentedon Dec 20, 2017
@geoffbeaumont Isn’t dropping
:beforerelated to dropping old IEs support? Modern browsers require just single::afterto clearfix correctly. See http://cssmojo.com/the-very-latest-clearfix-reloaded/.geoffbeaumont commentedon Dec 20, 2017
@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.
Kout commentedon Dec 20, 2017
@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
merge after v4-beta3 release
geoffbeaumont commentedon Jan 2, 2018
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.