Skip to content

margin collapsing with "clearfix" fallback #3

@revyh

Description

@revyh

flow-root creates new BFC on element, wich prevent margins of children elements from "leaking". column-count and overflow fallbacks also creates new BFC, so there is no problems with them. But clearfix fallback doesn't create new BFC and margin-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

.clearfix::after {
  content: '';
  display: table;
  clear: both;
}

to

.clearfix::before,
.clearfix::after {
  content: '';
  display: table;
}

.clearfix::after {
  clear: both;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions