| commit | author | age | ||
| 83c3f6 | 1 | --- |
| SP | 2 | layout: docs |
| 3 | title: Float | |
| 4 | description: Toggle floats on any element, across any breakpoint, using our responsive float utilities. | |
| 5 | group: utilities | |
| 6 | toc: true | |
| 7 | --- | |
| 8 | ||
| 9 | ## Overview | |
| 10 | ||
| 11 | 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](https://developer.mozilla.org/en-US/docs/Web/CSS/float). `!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. | |
| 12 | ||
| 13 | ## Classes | |
| 14 | ||
| 15 | Toggle a float with a class: | |
| 16 | ||
| 17 | {% capture example %} | |
| 18 | <div class="float-left">Float left on all viewport sizes</div><br> | |
| 19 | <div class="float-right">Float right on all viewport sizes</div><br> | |
| 20 | <div class="float-none">Don't float on all viewport sizes</div> | |
| 21 | {% endcapture %} | |
| 22 | {% include example.html content=example %} | |
| 23 | ||
| 24 | ## Mixins | |
| 25 | ||
| 26 | Or by Sass mixin: | |
| 27 | ||
| 28 | {% highlight scss %} | |
| 29 | .element { | |
| 30 | @include float-left; | |
| 31 | } | |
| 32 | .another-element { | |
| 33 | @include float-right; | |
| 34 | } | |
| 35 | .one-more { | |
| 36 | @include float-none; | |
| 37 | } | |
| 38 | {% endhighlight %} | |
| 39 | ||
| 40 | ## Responsive | |
| 41 | ||
| 42 | Responsive variations also exist for each `float` value. | |
| 43 | ||
| 44 | {% capture example %} | |
| 45 | <div class="float-sm-left">Float left on viewports sized SM (small) or wider</div><br> | |
| 46 | <div class="float-md-left">Float left on viewports sized MD (medium) or wider</div><br> | |
| 47 | <div class="float-lg-left">Float left on viewports sized LG (large) or wider</div><br> | |
| 48 | <div class="float-xl-left">Float left on viewports sized XL (extra-large) or wider</div><br> | |
| 49 | {% endcapture %} | |
| 50 | {% include example.html content=example %} | |
| 51 | ||
| 52 | Here are all the support classes; | |
| 53 | ||
| 54 | {% for bp in site.data.breakpoints %} | |
| 55 | - `.float{{ bp.abbr }}-left` | |
| 56 | - `.float{{ bp.abbr }}-right` | |
| 57 | - `.float{{ bp.abbr }}-none`{% endfor %} | |