Flex
Quickly manage the layout, alignment, and sizing of grid columns and other elements. For more complex implementations, custom CSS may be necessary. To learn flexbox read a flexbox guide.
To enable flexbox layout use display utilities like .d-flex
, .d-inline-flex
and their responsive variations.
<div class="d-flex"> I'm a flexbox container! All children inside me will behave in according to flexbox. </div>
Flex container's classes
Direction
Set the direction of flex items in a flex container. In most cases you can omit the horizontal class here as the browser default is row
. However, you may encounter situations where you needed to explicitly set this value (like responsive layouts).
.flex
-sm
-md
-lg
-xl
-row
-column
-row-reverse
-column-reverse
.flex-row-reverse
Wrap
.flex
-sm
-md
-lg
-xl
-wrap
-nowrap
-wrap-reverse
.flex-wrap
Justify content
.justify-content
-sm
-md
-lg
-xl
-start
-end
-center
-between
-around
.justify-content-between
Align items
.align-items
-sm
-md
-lg
-xl
-start
-end
-center
-baseline
-stretch
.align-items-center
Align content
This property has no effect on single rows of flex items. To demonstrate these utilities, we’ve enforced flex-wrap: wrap
and increased the number of flex items.
.align-content
-sm
-md
-lg
-xl
-start
-end
-center
-between
-around
-stretch
.align-content-end
Children's classes
Fill
.flex
-sm
-md
-lg
-xl
-fill
Use the .flex-fill
class on a series of sibling elements to force them into equal widths while taking up all available horizontal space.
<div class="d-flex"> <div class="p-2 example">No fill</div> <div class="p-2 flex-fill example">Equal</div> <div class="p-2 flex-fill example">Equal</div> </div>
Grow and shrink
Use .flex-grow-*
utilities to toggle a flex item’s ability to grow to fill available space.
.flex
-sm
-md
-lg
-xl
-grow-0
-grow-1
.flex-grow-0
Use .flex-shrink-*
utilities to toggle a flex item’s ability to shrink if necessary.
.flex
-sm
-md
-lg
-xl
-shrink-0
-shrink-1
.flex-shrink-0
Lorem ipsum, dolor sit
Align self
.align-self
-sm
-md
-lg
-xl
-auto
-start
-end
-center
-baseline
-stretch
.align-self-end
Order
Change the visual order of specific flex items with order utilities. With this classes you can also change order of grid columns since Setka's grid build with flexbox layout.
.order
-sm
-md
-lg
-xl
-0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
.order-0