Overview of Twitter Bootstrap 3 & Grid System

Bootstrap is a front-end toolkit open sourced by Twitter which provides flexible HTML, CSS, and JavaScript-based design templates, a variety of UI components and interactions for building a beautiful website. Bootstrap supports these main features:

– Grid System

– Responsive Design

– CSS with a Clean and Organized Look

– CSS preprocessor (LESS)

In this chapter, i want to introduce deeply about Grid System – very important feature of Bootstrap. Let’s discuss other features in these next chapters.

I. Basic of Grid System

The default grid system utilizes a 12-column grid that renders out at the width of 940 pixels. A row is expressed by using “row” class, and there are 4 column size class variants for corresponding devices:

col-xs-* (phones)

col-sm-* (tablets)

col-md-* (desktops)

col-lg-* (larger desktops)

The col-md-* (for example) can be col-md-1, col-md-2…., col-md-12. The space between columns is 20 pixels and the width of col-md-1 is 60 pixel, so the width of col-md-12 is (60 + 20) x 12 – 20 = 940 pixel

Figure 1.1 – column Grid System

II. How to use

The best way to understand Grid System is taking some examples. You will find out that it’s pretty simple.

Three equal columns

Get three equal-width columns starting at desktops and scaling to large desktops. On mobile devices, tablets and below, the columns will automatically stack.

Three unequal columns

Get three columns starting at desktops and scaling to large desktops of various widths. Remember, grid columns should add up to twelve for a single horizontal block. More than that, and columns start stacking no matter the viewport.

Two columns with two nested columns

Per the documentation, nesting is easy—just put a row of columns within an existing row. This gives you two columns starting at desktops and scaling to large desktops, with another two (equal widths) within the larger column. At mobile device sizes, tablets and down, these columns and their nested columns will stack.

Mixed: mobile and desktop

The Bootstrap 3 grid system has four tiers of classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). You can use nearly any combination of these classes to create more dynamic and flexible layouts. Each tier of classes scales up, meaning if you plan on setting the same widths for xs and sm, you only need to specify xs.

Offset, push, and pull resets

Reset offsets, pushes, and pulls at specific breakpoints.

That’s all the basic of Grid System.

Building website layout with Bootstrap Grid System is wonderful and simple, right?