Helpers
Clearfix
Clear floated content inside a container with a single class.
How it works
Add .clearfix to a parent whose children are floated. The helper puts an empty
::after pseudo-element with clear: both at the end, so the parent grows to wrap
its floats. Nothing about it changes in this theme; it is listed here because the
float utilities depend on it.
<div class="clearfix">…</div>
Or use the mixin in your own Sass.
.element {
@include clearfix;
}
Example
Two floated buttons. Without .clearfix the bordered wrapper would collapse to zero height and the
buttons would hang outside it.
HTML
<div class="bg-info clearfix rounded-1 p-2">
<button type="button" class="btn btn-secondary float-start">Red corner</button>
<button type="button" class="btn btn-secondary float-end">Blue corner</button>
</div>Compare the same markup with the helper removed. The wrapper is only as tall as its padding.
HTML
<div class="bg-info rounded-1 p-2 mb-7">
<button type="button" class="btn btn-secondary float-start">Red corner</button>
<button type="button" class="btn btn-secondary float-end">Blue corner</button>
</div>