{ { < callout info }} Heads up! Be sure to read the Grid page first before diving into how to modify and customize your grid columns. { { < /callout }}
How they work#
-
Columns build on the grid's flexbox architecture. Flexbox means we have options for changing individual columns and modifying groups of columns at the row level. You choose how columns grow, shrink, or otherwise change.
-
When building grid layouts, all content goes in columns. The hierarchy of Bootstrap's grid goes from container to row to column to your content. On rare occasions, you may combine content and column, but be aware there can be unintended consequences.
-
**Bootstrap includes predefined classes for creating fast, responsive layouts. ** With six breakpoints and a dozen columns at each grid tier, we have dozens of classes already built for you to create your desired layouts. This can be disabled via Sass if you wish.
Alignment#
Use flexbox alignment utilities to vertically and horizontally align columns.
Vertical alignment#
Change the vertical alignment with any of the responsive align-items-*
classes.
{ { < example class="bd-example-row bd-example-row-flex-cols" }}
{ {< /example >} }
{ { < example class="bd-example-row bd-example-row-flex-cols" }}
{ {< /example >} }
{ { < example class="bd-example-row bd-example-row-flex-cols" }}
{ {< /example >} }
Or, change the alignment of each column individually with any of the responsive
.align-self-*
classes.
{ { < example class="bd-example-row bd-example-row-flex-cols" }}
{ {< /example >} }
Horizontal alignment#
Change the horizontal alignment with any of the responsive justify-content-*
classes.
{ { < example class="bd-example-row" }}
{ {< /example >} }
Column wrapping#
If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
{ { < example class="bd-example-row" }}
Since 9 + 4 = 13 > 12, this 4-column-wide div gets wrapped onto a new line as one contiguous unit.
Subsequent columns continue along the new line.
{ {< /example >} }
Column breaks#
Breaking columns to a new line in flexbox requires a small hack: add an element
with width: 100%
wherever you want to wrap your columns to a new line.
Normally this is accomplished with multiple .row
s, but not every
implementation method can account for this.
{ { < example class="bd-example-row" }}
{ {< /example >} }
You may also apply this break at specific breakpoints with our responsive display utilities.
{ { < example class="bd-example-row" }}
{ {< /example >} }
Reordering#
Order classes#
Use .order-
classes for controlling the visual order of your content.
These classes are responsive, so you can set the order
by breakpoint (e.g.,
.order-1.order-md-2
). Includes support for 1
through 5
across all six grid
tiers. If you need more .order-*
classes, you can modify the default number
via Sass variable.
{ { < example class="bd-example-row" }}
{ {< /example >} }
There are also responsive .order-first
and .order-last
classes that change
the order
of an element by applying order: -1
and order: 6
, respectively.
These classes can also be intermixed with the numbered .order-*
classes as
needed.
{ { < example class="bd-example-row" }}
{ {< /example >} }
Offsetting columns#
You can offset grid columns in two ways: our responsive .offset-
grid classes
and our margin utilities. Grid classes
are sized to match columns while margins are more useful for quick layouts where
the width of the offset is variable.
Offset classes#
Move columns to the right using .offset-md-*
classes. These classes increase
the left margin of a column by *
columns. For example, .offset-md-4
moves
.col-md-4
over four columns.
{ { < example class="bd-example-row" }}
{ {< /example >} }
In addition to column clearing at responsive breakpoints, you may need to reset offsets. See this in action in the grid example.
{ { < example class="bd-example-row" }}
{ {< /example >} }
Margin utilities#
With the move to flexbox in v4, you can use margin utilities like .me-auto
to
force sibling columns away from one another.
{ { < example class="bd-example-row" }}
{ {< /example >} }
Standalone column classes#
The .col-*
classes can also be used outside a .row
to give an element a
specific width. Whenever column classes are used as non-direct children of a
row, the paddings are omitted.
{ { < example class="bd-example-row" }}
{ {< /example >} }
The classes can be used together with utilities to create responsive floated
images. Make sure to wrap the content in a .clearfix
wrapper to clear the float if the text is shorter.
{ {< example >} }
A paragraph of placeholder text. We're using it here to show the use of the clearfix class. We're adding quite a few meaningless phrases here to demonstrate how the columns interact here with the floated image.
As you can see the paragraphs gracefully wrap around the floated image. Now imagine how this would look with some actual content in here, rather than just this boring placeholder text that goes on and on, but actually conveys no tangible information at. It simply takes up space and should not really be read.
And yet, here you are, still persevering in reading this placeholder text, hoping for some more insights, or some hidden easter egg of content. A joke, perhaps. Unfortunately, there's none of that here.
{ {< /example >} }