Easily clear floats by adding .clearfix to the parent element.


<div class="clearfix">...</div>

The following example shows how the clearfix can be used. Without the clearfix, the wrapping div would not span the buttons, which would cause a broken layout.

<div class="bg-dark clearfix">
  <button class="btn btn-secondary float-left">Example Button Floated Left</button>
  <button class="btn btn-secondary float-right">Example Button Floated Right</button>
</div>
Last updated August 12, 2021.