Grid

The grid is 12 columns and percentage-based. The number of columns a container spans can be adjusted across breakpoints for responsive layouts. The grid system works with a variety of layout utilities to achieve different results.

Float based grid

Use .clearfix on the container and float utilities with columns for a floated grid layout.

Reversed grid

To reverse the order of columns, use float-right to float columns to the right.

Nesting

You can infinitely nest grid layouts within other columns since the column widths are percentage based. With great flexibility comes great responsibility - be sensible with how far you nest!

Centering a column

Use .mx-auto to center columns within a container.

Column widths

Column widths can be used with any other block or inline-block elements to add percentage-based widths.

<div>
<div class="col-4 float-right p-2 border text-red">
<%= octicon "heart" %> Don't go bacon my heart.
</div>
<p>T-bone drumstick alcatra ribeye. Strip steak chuck andouille tenderloin bacon tri-tip ball tip beef capicola rump. Meatloaf bresaola drumstick ball tip salami. Drumstick ham bacon alcatra pig porchetta, spare ribs leberkas pork belly.</p>
</div>

Offset columns

Using column offset classes can push a div over X number of columns. They work responsively using the breakpoints outlined below.

Gutters

Use gutter styles or padding utilities to create gutters. You can use the default gutter style, gutter, or either of its modifiers, gutter-condensed or gutter-spacious. Gutter styles also support responsive breakpoint modifiers. Gutter styles add padding to the left and right side of each column and apply a negative margin to the container to ensure content inside each column lines up with content outside of the grid.

Use padding utilities to create gutters for more customized layouts.

Inline-block grids

Use column widths with d-inline-block as an alternative to floated grids.

You can use column widths and other utilities on elements such as lists to create the layout you need while keeping the markup semantically correct.

Display table grids

Using display table utilities with columns gives you some alternative layout options.

A useful example is being able to keep the height of the container equal across a row when the length of content may differ.

You can also create an alternative media object layout with .display-table and column widths.

Note that table cells will fill the width of their container even when the total columns doesn't add up to 12.

Flexbox grids

You can use flex utilities on the container and columns to create a flexbox grid.

This can be useful for keeping columns the same height, justifying content and vertically aligning items. The flexbox grid is also great for working with responsive layouts.

Responsive grids

All the column width classes can be set per breakpoint to create responsive grid layouts. Each responsive style is applied to the specified breakpoint and up.

Breakpoints

We use abbreviations for each breakpoint to keep the class names concise.

ShorthandDescription
smmin-width: 544px
mdmin-width: 768px
lgmin-width: 1004px
xlmin-width: 1280px

Note: The lg breakpoint matches our current page width of 980px including left and right padding of 12px. This is so that content doesn't touch the edges of the window when resized.


In this example at the sm breakpoint 2 columns will show, at the md breakpoint 4 columns will show, and at the lg breakpoint 6 columns will show.

For demonstration, this is how the above example would look at the sm breakpoint.

This is how that same example would look at the md breakpoint.

This is how that example would look at the lg breakpoint.

Containers

Container widths match our breakpoints and are available at a sm, md, lg, and xl size. Containers apply a max-width rather than a fixed width for responsive layouts, and they center the container.

Edit this page on GitHub
1 contributorcolebemis
Last edited by colebemis on August 12, 2019