Below are some examples of basic Bootstrap grid layouts.
Three Equal Columns
-----example mukavu -----
The following example demonstrates how to achieve three equal-width columns beginning with tablets and scaling to huge desktops. On mobile phones, the columns automatically stack:
Example
.col-sm-3
.col-sm-6
.col-sm-3
Two Unequal Columns
The following example demonstrates how to create two columns of varying widths, beginning with tablets and scaling to huge desktops:
-----example mukavu -----
Example
.col-sm-4
.col-sm-8
No gutters
-----example mukavu -----
Use the .row-no-gutters class to remove the gutters from a row and its columns.
Example
.col-sm-3
.col-sm-6
.col-sm-3
Two Columns With Two Nested Columns
The following example demonstrates how to get two columns starting at tablets and scaling to huge desktops, with another two columns (equal widths) within the larger column (at mobile phones, these columns and their nested columns stack):
Example
.col-sm-8
.col-sm-6
.col-sm-6
.col-sm-4
Mixed: Mobile And Desktop
Bootstrap’s grid structure has four classes: xs (phones), sm (tablets), md (desktops), and lg (bigger desktops). Classes can be merged to create more dynamic and adaptable layouts.
Tip: Because each class scales up, you can define the same widths for xs and sm by specifying only xs.
Example
.col-xs-9 .col-md-7
.col-xs-3 .col-md-5
.col-xs-6 .col-md-10
.col-xs-6 .col-md-2
.col-xs-6
.col-xs-6
Tip: Remember that grid columns should sum up to twelve per row. Columns will stack regardless of the viewport.
Mixed: Mobile, Tablet And Desktop
Example
.col-xs-7 .col-sm-6 .col-lg-8
.col-xs-5 .col-sm-6 .col-lg-4
.col-xs-6 .col-sm-8 .col-lg-10
.col-xs-6 .col-sm-4 .col-lg-2
Clear Floats
Clear floats (using the .clearfix class) at certain breakpoints to avoid unexpected wrapping with unequal content:
Example
Column 1
Resize the browser window to see the effect.
Column 2
Column 3
Column 4
Offsetting Columns
Columns can be moved to the right using the .col-md-offset-* class. These classes extend a column’s left margin by * columns.
Example
.col-sm-5 .col-md-6
Push And Pull - Change Column Ordering
Change the order of the grid columns using the .col-md-push-* and .col-md-pull-*classes: