Rows and columns

Create responsive layouts and align content using our grid system, comprising rows and columns.

Rows and columns are built using flexbox, meaning that our range of flexbox utilities can be used to modify their appearance.

Rows

Use .row to wrap column elements.

The space between columns (gutter) is created by horizontal padding on each column element, which rows offset to ensure that content within columns is aligned with regular content on the left and right sides.

<div class="row">
  <div class="col">
    One of three columns
  </div>
  <div class="col">
    One of three columns
  </div>
  <div class="col">
    One of three columns
  </div>
</div>

Use the .row-sm or .row-lg modifiers to create rows with less or more gutter space, respectively:

<div class="row row-sm">
  <div class="col">
    One of three columns
  </div>
  <div class="col">
    One of three columns
  </div>
  <div class="col">
    One of three columns
  </div>
</div>

<div class="row row-lg">
  <div class="col">
    One of three columns
  </div>
  <div class="col">
    One of three columns
  </div>
  <div class="col">
    One of three columns
  </div>
</div>

Columns

Fluid width

Use .col-{width} to create a column that spans a given number of columns out the default 12 per row. For example, three equal-width columns would use .col-4.

<div class="row">
  <div class="col-4">
    One of three columns
  </div>
  <div class="col-4">
    One of three columns
  </div>
  <div class="col-4">
    One of three columns
  </div>
</div>

Column widths are set in percentages, so they’re always fluid and sized relative to the parent row.

If more than 12 columns are placed within a single row, they will wrap onto a new line.

Use .{screen}:col-{width} to have a column occupy that width at a specific breakpoint and above.

For example, .md:col-6 will span 6 of 12 columns at only medium screen sizes and above:

Responsive columns
View code
7af2485e411539b55d6d08d903e7d03e0896b7eb4aba15dcfa074c577edad78dc3358cb2366c3a244816aa1455ccbc196a675c5f30c57641072a5e33e08ea61fd836f25eadc7902b8f60497461a8a742fd59ce528f09184b1aeb009c67b394463c3671fa04bdb99e2c52cd5a896d28a3b702e84c479501b39ad6ac3f56132a6de57d59b5a93ef49d5d6e366ec4a542b092cd83973f1f4a74b7e22c6332ca04c2ed026eb23f4620752aea50592b56941a2725f3799662f43d3078d6829e3e0c29c46ee4a83267c88359e89439fd72527f12f1700c5e61a04173572d3be9f895582f3cb9cde2e0931edb5694826b43bb15427b158802f10d4db09e237b968fbf87376e8f97ad740ad6fdbc1cb8871296cac84d440642c4d78861487e07eb9e812230f0e0921d0338b490cbc69d8c6bf68b803090a201970ee1875dc1435763feff4884e7e1f4fd2a9475c1fed29981c996a3b3f434ad6b1efa1bf9d6ed2df3cb60b8beb2477cb53aafab0f30195eb30b43e50a0088681b21b6f18bf9f8f3ef5a4c52d518b73f80b3de93cf888a5429519f705f2791acda71e86b5c01bfeee60f8ed891083355b3c41ee1b7da2db44d1c78494a9b3119d3ccf1bc1a4814f6bd68229f0f56121f501ca42f980862d8374a6860f9b709ddd7ce751d44a451c08ee9cfb31d78dbb6d4afa531e4763162c4f2ad785fb1edd3956f4a4360df4cccb30718f6d121ac3d262e44e6d184a855549836297db543eb6e974c171df947c8fd815606a5c8486d25bed31e7bb9ba40cb25dc6dd698c1ed490ab6cbd958075b371973100b1ee4b9bf070c55c48847870b2c5ef477166b11e40d796a6646b35a3cd26ac430e26c43f83d7b1f40ae19d815033aada29af02b2cfd3ffb5854a206b1e39ab21ecddbcb6a1126481feb446bb563e20f0a8d001cf0cdf15c16b889c1af32521ebf60d9ae75ac352ba56940a95d3cf34f34477fb4cdf8cb7aa9eb620e8b544f347de301c2b42bf2202280ab7fdb6b1c5e04935238435d002350792f3b3fc5f280ab4b13bfbdb25a0fc54b0cf5879f3b8c069aa919cf7e27678b002b48cde1358e324e28a24e262d70607691cd1001f9a8ba2741024b1e65e3bc0ca94a671f80297deb8a3189a90f71cc2874ac6f4a9463996e0d00928102d83782442420504b72775d3b7a940a514562c7a0133eb6b6d57192dbe10fe680d100732f91aa69e2549ab9a6e78dc92770019e68d496900915e46986cb318c2a7bc478cd5b12036611785e7db0dfb522135968b57d40931fe61b47c4d97ab296907fb1e30f9706092aaa4d49f08419ffb6eb4baaa9b20d99014fca47e4e72ed818f8ca528f8ca16965c9b146b019d1ecbc4a5fbb02f23e2b592f8e7575e0e95c21b46553194f0c07c6d1e9bfe61159e7a2715fc16581aff5db782f53f41f6b7d5b7d0cc34341b4f2374514e9cde92011f2d35847513e945b4d2dde4e4ce7e45c0c7532c808524b3cd59451d6c1237800dc81462dc2f240fa641dd71657a5a4e6a99b528e4f33fa301baf5b5ddf8426d8a4dbe1f5ffb71a44b851d03db11b84174a85845e34369651

Equal-width

Columns without a specified {width} will automatically layout as equal width columns:

<div class="container">
  <div class="row">
    <div class="col">1 of 2</div>
    <div class="col">2 of 2</div>
  </div>
  <div class="row">
    <div class="col">1 of 3</div>
    <div class="col">2 of 3</div>
    <div class="col">3 of 3</div>
  </div>
</div>

Equal-width columns can be broken into multiple lines using the .w-full utility.

<div class="container">
  <div class="row">
    <div class="col">Column</div>
    <div class="col">Column</div>
    <div class="w-full"></div>
    <div class="col">Column</div>
    <div class="col">Column</div>
  </div>
</div>

Given flexbox behavior, you can set the width of one column and have the sibling columns automatically resize around it:

<div class="container">
  <div class="row">
    <div class="col">1 of 3</div>
    <div class="col-6">2 of 3 (wider)</div>
    <div class="col">3 of 3</div>
  </div>
  <div class="row">
    <div class="col">1 of 3</div>
    <div class="col-5">2 of 3 (wider)</div>
    <div class="col">3 of 3</div>
  </div>
</div>

Horizontal alignment

Use a justify-content utility to control the alignment of columns within a horizontal row.

<div class="container">
  <div class="row justify-content-start">
    <div class="col-4">One of two columns</div>
    <div class="col-4">One of two columns</div>
  </div>
  <div class="row justify-content-center">
    <div class="col-4">One of two columns</div>
    <div class="col-4">One of two columns</div>
  </div>
  <div class="row justify-content-end">
    <div class="col-4">One of two columns</div>
    <div class="col-4">One of two columns</div>
  </div>
  <div class="row justify-content-around">
    <div class="col-4">One of two columns</div>
    <div class="col-4">One of two columns</div>
  </div>
  <div class="row justify-content-between">
    <div class="col-4">One of two columns</div>
    <div class="col-4">One of two columns</div>
  </div>
</div>

Vertical alignment

Use an align-items utility to control the alignment of columns within a vertical row.

<div class="container">
  <div class="row align-items-start">
    <div class="col">One of three columns</div>
    <div class="col">One of three columns</div>
    <div class="col">One of three columns</div>
  </div>
  <div class="row align-items-center">
    <div class="col">One of three columns</div>
    <div class="col">One of three columns</div>
    <div class="col">One of three columns</div>
  </div>
  <div class="row align-items-end">
    <div class="col">One of three columns</div>
    <div class="col">One of three columns</div>
    <div class="col">One of three columns</div>
  </div>
</div>

Columns can be aligned independently of one another using an align-self utility.

<div class="container">
  <div class="row">
    <div class="col align-self-start">One of three columns</div>
    <div class="col align-self-center">One of three columns</div>
    <div class="col align-self-end">One of three columns</div>
  </div>
</div>

Reordering

Use .col-order-{position} to control the visual order of columns, where {position} is a value between 1 and 12 (the total number of columns).

<div class="row">
  <div class="col col-order-2">
    .col-order-2
  </div>
  <div class="col col-order-3">
    .col-order-3
  </div>
  <div class="col col-order-1">
   .col-order-1
  </div>
</div>

These classes are responsive, so you can set the visual order by breakpoint (e.g., .col-order-1.md:col-order-2).

Use .flex-first and .flex-last utilities to display a column at the start or end of a row, respectively:

<div class="row">
  <div class="col">
    First, but unordered
  </div>
  <div class="col flex-last">
    Second, but last
  </div>
  <div class="col flex-first">
    Third, but first
  </div>
</div>

Offsetting

Columns can be offset using responsive .offset-{number} classes, or 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

Use .{screen:}offset-{number} classes to move columns to the right using.

For example, .md:offset-4 moves a given column to the right by four columns widths for medium screen sizes and above.

<div class="row">
  <div class="col-4 md:col-offset-2">
    .col-4.md:col-offset-2
  </div>
  <div class="col-4">
    .col-4
  </div>
</div>

Margin utilities

You can use margin utilities like .mr-auto to force sibling columns away from one another.

<div class="row">
  <div class="col-4 mr-auto">
    .col-4.mr-auto
  </div>
  <div class="col-4">
    .col-4
  </div>
</div>

Nesting

Add a new .row and set of .sm:col-* columns within an existing .sm:col-* column to create a nested row.

Customizing

When using the source Sass files, you can customize the number of columns and column gap:

$column-number: 12;
$column-gap:    2rem;
$column-gap-sm: 1.5rem;
$column-gap-lg: 3rem;

Questions or feedback about this article? Let us know