Grid Options - based on Bootstrap Grid system overview

While Bootstrap uses ems or rems for defining most sizes, pxs are used for grid breakpoints and container widths. This is because the viewport width is in pixels and does not change with the font size. See how aspects of the Bootstrap grid system work across multiple devices with a handy table.

Extra small
<576px
Small
≥576px
Medium
≥768px
Large
≥992px
Extra large
≥1200px
Max container width None (auto) 540px 720px 960px 1140px
Class prefix .col- .col-sm- .col-md- .col-lg- .col-xl-
# of columns 12
Gutter width 30px (15px on each side of a column)
Nestable Yes
Column ordering Yes

Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, applying any .col-md-class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg-class is not present.

How it works Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.

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

The above example creates three equal-width columns on small, medium, large, and extra large devices using our predefined grid classes. Those columns are centered in the page with the parent .container.

Breaking it down, here’s how it works:

  • Containers provide a means to center and horizontally pad your site’s contents. Use .containerfor a responsive pixel width or .container-fluidfor width: 100%across all viewport and device sizes.
  • Rows are wrappers for columns. Each column has horizontal padding(called a gutter) for controlling the space between them. This paddingis then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.
  • In a grid layout, content must be placed within columns and only columns may be immediate children of rows.
  • Thanks to flexbox, grid columns without a specified widthwill automatically layout as equal width columns. For example, four instances of .col-smwill each automatically be 25% wide from the small breakpoint and up. See the auto-layout columnssection for more examples.
  • Column classes indicate the number of columns you’d like to use out of the possible 12 per row. So, if you want three equal-width columns across, you can use .col-4.
  • Column widths are set in percentages, so they’re always fluid and sized relative to their parent element.
  • Columns have horizontal paddingto create the gutters between individual columns, however, you can remove the marginfrom rows and paddingfrom columns with .no-gutterson the .row.
  • To make the grid responsive, there are five grid breakpoints, one for each responsive breakpoint: all breakpoints (extra small), small, medium, large, and extra large.
  • Grid breakpoints are based on minimum width media queries, meaning they apply to that one breakpoint and all those above it(e.g., .col-sm-4applies to small, medium, large, and extra large devices, but not the first xsbreakpoint).
  • You can use predefined grid classes (like .col-4) or Sass mixins for more semantic markup.

Full documentation presenting all available options and examples you can find on: http://getbootstrap.com/docs/4.1/layout/grid/