Float
Toggle floats on any element, across any breakpoint.
prop
.float
[breakpoint]
-sm
-md
-lg
-xl
value
-left
-right
-none
prop
.clearfix
These utility classes float an element to the left or right, or disable floating, based on the current viewport size using the CSS float
property. !important
is included to avoid specificity issues. These use the same viewport breakpoints as our grid system. Please be aware float utilities have no affect on flex items.
Examples
Float left on all viewport sizes
Float right on all viewport sizes
Don't float on all viewport sizes
<div class="float-left">Float left on all viewport sizes</div><br> <div class="float-right">Float right on all viewport sizes</div><br> <div class="float-none">Don't float on all viewport sizes</div>
Responsive variations also exist for each float
value.
Float right on viewports sized SM (small) or wider
Float left on viewports sized MD (medium) or wider
Float right on viewports sized LG (large) or wider
Float left on viewports sized XL (extra-large) or wider
<div class="float-sm-right">Float right on viewports sized SM (small) or wider</div><br> <div class="float-md-left">Float left on viewports sized MD (medium) or wider</div><br> <div class="float-lg-right">Float right on viewports sized LG (large) or wider</div><br> <div class="float-xl-left">Float left on viewports sized XL (extra-large) or wider</div><br>
Clearfix
Easily clear float
s by adding .clearfix
to the parent element. Can also be used as a Stylus mixin.
The following example shows how the clearfix can be used.
Example Button floated left
Example Button floated right
<div class="example clearfix"> <div class="bg-2 float-left">Example Button floated left</div> <div class="bg-2 float-right">Example Button floated right</div> </div>
Without the clearfix the wrapping div would not span around the buttons which would cause a broken layout.
Example Button floated left
Example Button floated right