-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
margin collapsing with "clearfix" fallback #3
Comments
Does your second example have any trade offs? Seems to work over here—creates a new BFC and disables margin collapsing. |
@OliverJAsh I don't clearly understand what do you mean by "second example" and "trade offs". I suggest, that you compare second code snippet in this issue with browser implementation of If so, then main trade off is that clearfix doesn't really creates new BFC (more on this in another issue). If you want to use |
As you have pointed out, the currently used
However, margin collapsing can be prevented by switching this to use the http://output.jsbin.com/poquxa/3 I wonder if there are any drawbacks to using this alternative clearfix? I was considering using |
In fact this seems to work as well: .clearfix::before,
.clearfix::after {
content: '';
display: table;
} |
@OliverJAsh I think I better explain in terms of this article. BFC can do many things:
I think, that choice of fallback depends on whether you plan to prevents text wrapping or not. If you don't care about this, then you can go with clearfix. |
flow-root
creates new BFC on element, wich prevent margins of children elements from "leaking".column-count
andoverflow
fallbacks also creates new BFC, so there is no problems with them. Butclearfix
fallback doesn't create new BFC andmargin-top
"leaks" from children elements.Here is the simple pen that illustrates this issue.
If we want to be closer to spec, than we should replace clearfix from
to
The text was updated successfully, but these errors were encountered: