Bootstrap Grid Offset

Posted onby admin
Bootstrap
  1. Col Md 6
  2. Bootstrap Grid Examples

Below we have collected some examples of basic Bootstrap grid layouts.

In this article we shall study yet another awesome bootstrap trick i.e. Bootstrap grid offset column. You might want to create single layout div which spans 6 columns and which is centered on the screen i.e three columns from the left and three columns from the right. You can create such layouts using bootstrap grid offset column property. Bootstrap's grid system is responsive, and the columns will re-arrange depending on the screen size: On a big screen it might look better with the content organized in three columns, but on a small screen it would be better if the content items were stacked on top of each other. That padding is offset in rows for the first and last column.

Three Equal Columns

.col-sm-4

The following example shows how to get a three equal-width columns starting at tablets and scaling to large desktops. On mobile phones, the columns will automatically stack:

Example

<div>
<div>.col-sm-4</div>
<div>.col-sm-4</div>
<div>.col-sm-4</div>
</div>
Try it Yourself »

Three Unequal Columns

.col-sm-6

The following example shows how to get a three various-width columns starting at tablets and scaling to large desktops:

Example

<div>
<div>.col-sm-3</div>
<div>.col-sm-6</div>
<div>.col-sm-3</div>
</div>
Try it Yourself »

Two Unequal Columns

.col-sm-8

The following example shows how to get two various-width columns starting at tablets and scaling to large desktops:

Example

<div>
<div>.col-sm-4</div>
<div>.col-sm-8</div>
</div>
TableTry it Yourself »Grid

No gutters

.col-sm-8

Use the .row-no-gutters class to remove the gutters from a row and its columns:

Bootstrap

Example

<div>
<div>.col-sm-3</div>
<div>.col-sm-6</div>
<div>.col-sm-3</div>
</div>
Try it Yourself »

Two Columns With Two Nested Columns

The following example shows how to get two columns starting at tablets and scaling to large desktops, with another two columns (equal widths) within the larger column (at mobile phones, these columns and their nested columns will stack):

Example

<div>
<div>
.col-sm-8
<div>
<div>.col-sm-6</div>
<div>.col-sm-6</div>
</div>
</div>
<div>.col-sm-4</div>
</div>
Try it Yourself »

Mixed: Mobile And Desktop

The Bootstrap grid system has four classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). The classes can be combined to create more dynamic and flexible layouts.

Tip: Each class scales up, so if you wish to set the same widths for xs and sm, you only need to specify xs.

Example

<div>
<div>.col-xs-9 .col-md-7</div>
<div>.col-xs-3 .col-md-5</div>
</div>
<div>
<div>.col-xs-6 .col-md-10</div>
<div>.col-xs-6 .col-md-2</div>
</div>
<div>
<div>.col-xs-6</div>
<div>.col-xs-6</div>
</div>
Try it Yourself »

Tip: Remember that grid columns should add up to twelve for a row. More than that, columns will stack no matter the viewport.

Mixed: Mobile, Tablet And Desktop

Example

<div>
<div>.col-xs-7 .col-sm-6 .col-lg-8</div>
<div>.col-xs-5 .col-sm-6 .col-lg-4</div>
</div>
<div>
<div>.col-xs-6 .col-sm-8 .col-lg-10</div>
<div>.col-xs-6 .col-sm-4 .col-lg-2</div>
</div>
Try it Yourself »

Clear Floats

Clear floats (with the .clearfix class) at specific breakpoints to prevent strange wrapping with uneven content:

Example

Col Md 6

<div>
<div>
Column 1
<br>
Resize the browser window to see the effect.
</div>
<div>Column 2</div>
<!-- Add clearfix for only the required viewport -->
<div></div>
<div>Column 3</div>
<div>Column 4</div>
</div>
Try it Yourself »

Offsetting Columns

Move columns to the right using .col-md-offset-* classes. These classes increase the left margin of a column by * columns:

Example

<div>
<div>.col-sm-5 .col-md-6</div>
<div>
</div>
Try it Yourself »

Push And Pull - Change Column Ordering

Change the order of the grid columns with .col-md-push-* and .col-md-pull-* classes:

Example

<div>
<div>.col-sm-4 .col-sm-push-8</div>
<div>.col-sm-8 .col-sm-pull-4</div>
</div>
Try it Yourself »
Grid

Bootstrap Grid Examples