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-light 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>
Last updated May 10, 2022.