loading

BS Grid Examples


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

				
					<div class="row">
  <div class="col-sm-3">.col-sm-3</div>
  <div class="col-sm-6">.col-sm-6</div>
  <div class="col-sm-3">.col-sm-3</div>
</div>
				
			

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

				
					<div class="row">
  <div class="col-sm-4">.col-sm-4</div>
  <div class="col-sm-8">.col-sm-8</div>
</div>
				
			

No gutters

-----example mukavu -----

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

Example

				
					<div class="row row-no-gutters">
  <div class="col-sm-3">.col-sm-3</div>
  <div class="col-sm-6">.col-sm-6</div>
  <div class="col-sm-3">.col-sm-3</div>
</div>
				
			

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

				
					<div class="row">
  <div class="col-sm-8">
    .col-sm-8
    <div class="row">
      <div class="col-sm-6">.col-sm-6</div>
      <div class="col-sm-6">.col-sm-6</div>
    </div>
  </div>
  <div class="col-sm-4">.col-sm-4</div>
</div>
				
			

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

				
					<div class="row">
  <div class="col-xs-9 col-md-7">.col-xs-9 .col-md-7</div>
  <div class="col-xs-3 col-md-5">.col-xs-3 .col-md-5</div>
</div>

<div class="row">
  <div class="col-xs-6 col-md-10">.col-xs-6 .col-md-10</div>
  <div class="col-xs-6 col-md-2">.col-xs-6 .col-md-2</div>
</div>

<div class="row">
  <div class="col-xs-6">.col-xs-6</div>
  <div class="col-xs-6">.col-xs-6</div>
</div>
				
			

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

				
					<div class="row">
  <div class="col-xs-7 col-sm-6 col-lg-8">.col-xs-7 .col-sm-6 .col-lg-8</div>
  <div class="col-xs-5 col-sm-6 col-lg-4">.col-xs-5 .col-sm-6 .col-lg-4</div>
</div>

<div class="row">
  <div class="col-xs-6 col-sm-8 col-lg-10">.col-xs-6 .col-sm-8 .col-lg-10</div>
  <div class="col-xs-6 col-sm-4 col-lg-2">.col-xs-6 .col-sm-4 .col-lg-2</div>
</div>
				
			

Clear Floats

Clear floats (using the .clearfix class) at certain breakpoints to avoid unexpected wrapping with unequal content:

Example

				
					<div class="row">
  <div class="col-xs-6 col-sm-3">
    Column 1
    <br>
    Resize the browser window to see the effect.
  </div>
  <div class="col-xs-6 col-sm-3">Column 2</div>
  <!-- Add clearfix for only the required viewport -->
  <div class="clearfix visible-xs"></div>
  <div class="col-xs-6 col-sm-3">Column 3</div>
  <div class="col-xs-6 col-sm-3">Column 4</div>
</div>
				
			

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

				
					<div class="row">
  <div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
  <div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">
</div>
				
			

Push And Pull - Change Column Ordering

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

Example

				
					<div class="row">
  <div class="col-sm-4 col-sm-push-8">.col-sm-4 .col-sm-push-8</div>
  <div class="col-sm-8 col-sm-pull-4">.col-sm-8 .col-sm-pull-4</div>
</div>
				
			
Share this Doc

BS Grid Examples

Or copy link

Explore Topic