In the hope that you’ve previously read the Introduction to Flexbox theory, let’s get deeper into Columns.
Utilize breakpoint-specific row classes for equal-height rows. Add any number of unit-less classes for each breakpoint you need and every row will be the same height.
Equal-height
For example, here are two grid layouts that apply to every device and viewport, from xs to xl.
Setting one row height
Auto-layout for flexbox grid rows also means you can set the height of one row and the others will automatically resize around it. You may use predefined grid classes (as shown below) or inline heights. Note that the other rows will resize no matter the height of the center row.
Variable height content
Using the col-{breakpoint}-auto
classes, rows can size itself based on the natural height of its content. This is super handy with single line content like inputs, numbers, etc. This, in conjunction with horizontal alignment classes, is very useful for centering layouts with uneven row sizes as viewport height changes.
Responsive classes
The grid includes five tiers of predefined classes for building complex responsive layouts. Customize the size of your rows on extra small, small, medium, large, or extra large devices however you see fit.
All breakpoints
For grids that are the same from the smallest of devices to the largest, use the .col
and .col-*
classes. Specify a numbered class when you need a particularly sized row; otherwise, feel free to stick to .col.
Mix and match
Don’t want your rows to simply stack in some grid tiers? Use a combination of different classes for each tier as needed. See the example below for a better idea of how it all works.
Alignment
Use flexbox alignment utilities to vertically and horizontally align columns.
TIP
There is also the convenience flex-center
CSS class which is equivalent to items-center
+ justify-center
. Use it along with flex
, row
or 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.
Reordering
Nesting
To nest your content with the default grid, add a new .row
and set of .col-sm-*
columns within an existing .col-sm-*
column. Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 available columns).
Flex Grid Playground
To see the Flex in action, you can use the Flex Playground to interactively learn more.
Flex Playgroundlaunch