Skip to content

Home

Clearfix

Ensures that an element self-clears its children.

💬 Note

This is only useful if you are using float to build layouts. Consider using a more modern approach, such as the flexbox or grid layout.

<div class="clearfix">
  <div class="floated">float a</div>
  <div class="floated">float b</div>
  <div class="floated">float c</div>
</div>
.clearfix::after {
  content: '';
  display: block;
  clear: both;
}

.floated {
  float: left;
  padding: 4px;
}

More like this

Start typing a keyphrase to see matching snippets.