The Tree of Widsdom

智慧の樹

About the Bootstrap grid system


To use the grid system, make a

. Now you have a row that is secretly a grid that is 12 squares across. If you make a div inside of this, it will be 12/12 squares across—the full width. But the point of the invisible squares is to make divs that span less than 12 squares across. Moreover, you can have the spans change automatically with the browser width.

Table: Bootstrap grid for Tinderboxers
PrefixMeaning
.col-xs-width = N/12 when container wider than 0
.col-sm-width = N/12 when container wider than 768px
.col-md-width = N/12 when container wider than 992px
.col-lg-width = N/12 when container wider than 1200px

Next concept: you can combine these.

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

This means: “When the browser is wider than 768px, each div is half-way across; when less than 768px, a third-way across.”

There is a hierarchy of precedence here. If the container is < lg, Bootstrap falls back on whatever you’ve set for md. If md has not been set, it looks at sm. If sm not set, then it looks to your setting for xs. If that is not set, the divs are stacked vertically.