Introduction to Bootstrap

Bootstrap is a really powerful framework and was developed by Twitter and makes websites responsive.

What is Bootstrap?

Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the Web. This webpage has been developed using Bootstrap.

What are containers?

Containers are the most basic layout in Bootstrap element and are required when using their Grid system.

There are two types of conatiners:

What are grids?

A horizontal row in Bootstrap is made up of 12 columns. So we can create sections of a row up to 12 columns total before it wraps around. In the example below we create four columns, the first is 4 columns wide, second and third are 3 columns, and the fourth is 2 columns wide.

Basic grid(s)

By default in Bootsrap there are 4 responsive breakpoints (xs, sm, md, lg, xl). The second attribute of grid class, for e.g. 'sm' in 'col-sm-4' deonotes the grid should occupy 4 columns in a viewport of that size and larger, AND if the size, in this example falls under a small then the column should stack (meaning take up the entire width of the viewport).

Having said that, we can combine as to when columns should stack. In the example below we have:

One of four columns (.col-xl-4)
Second of four columns (.col-lg-3)
Third of four columns (.col-md-3)
Fourth of four columns (.col-sm-2)

Same grid occupying different number of columns in different viewports

It is not necessary that a grid has to collapse. In other words it is also possible to make the same grid take up differen sizes in different viewport. To illustrate this I have modified the example above as following:

One of four columns (.col-xl-4)
Second of four columns (.col-lg-6 .col-xl-3 )
Third of four columns (.col-md-6 .col-lg-4 .col-xl-3)
Fourth of four columns (.col-sm-9 .col-md-6 .col-lg-2 .col-xl-2)

Moving grids to the right (offset)

It is possible to move columns to the right, in other words add gaps in between columns. Columns can be moved to the right using .col-*-offset-* class. The first asterisk can be replaced with the viewport (xs, sm, md, lg, xl) and the second asterisk with the number of columns to offset. For example, .col-md-offset-2 will offset the grid by 2 columns in viewport of medium size and larger. In the following example the 2nd grid has been offset by 2 columns in viewports of mediumd and larger.

.col-md-4
.col-md-4 .col-md-offset-2

Nesting grids

It is possible to nest a grid within a grid. To nest your content with the default grid, add a new .row and set of columns (.col-*-*) within an existing column (.col-*-*). Nested rows should include a set of columns that add up to 12 or fewer (it is not required that you use all 12 columns).

1st grid .col-md-6
.col-xs-4
.col-xs-4
.col-xs-4
.col-xs-4
2nd grid .col-md-6
.col-xs-4
.col-xs-4