{{_i}}Scaffolding{{/i}}

{{_i}}Bootstrap is built on responsive 12-column grids, layouts, and components.{{/i}}

{{_i}}Requires HTML5 doctype{{/i}}

{{_i}}Bootstrap makes use of certain HTML elements and CSS properties that require the use of the HTML5 doctype. Include it at the beginning of all your projects.{{/i}}

<!DOCTYPE html>
<html lang="en">
  ...
</html>

{{_i}}Typography and links{{/i}}

{{_i}}Bootstrap sets basic global display, typography, and link styles. Specifically, we:{{/i}}

  • {{_i}}Remove margin on the body{{/i}}
  • {{_i}}Set background-color: white; on the body{{/i}}
  • {{_i}}Use the @baseFontFamily, @baseFontSize, and @baseLineHeight attributes as our typographic base{{/i}}
  • {{_i}}Set the global link color via @linkColor and apply link underlines only on :hover{{/i}}

{{_i}}These styles can be found within scaffolding.less.{{/i}}

{{_i}}Reset via Normalize{{/i}}

{{_i}}With Bootstrap 2, the old reset block has been dropped in favor of Normalize.css, a project by Nicolas Gallagher that also powers the HTML5 Boilerplate. While we use much of Normalize within our reset.less, we have removed some elements specifically for Bootstrap.{{/i}}

{{_i}}Live grid example{{/i}}

{{_i}}The default Bootstrap grid system utilizes 12 columns, making for a 940px wide container without responsive features enabled. With the responsive CSS file added, the grid adapts to be 724px and 1170px wide depending on your viewport. Below 767px viewports, the columns become fluid and stack vertically.{{/i}}

1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
6
6
12

{{_i}}Basic grid HTML{{/i}}

{{_i}}For a simple two column layout, create a .row and add the appropriate number of .span* columns. As this is a 12-column grid, each .span* spans a number of those 12 columns, and should always add up to 12 for each row (or the number of columns in the parent).{{/i}}

<div class="row">
  <div class="span4">...</div>
  <div class="span8">...</div>
</div>

{{_i}}Given this example, we have .span4 and .span8, making for 12 total columns and a complete row.{{/i}}

{{_i}}Offsetting columns{{/i}}

{{_i}}Move columns to the right using .offset* classes. Each class increases the left margin of a column by a whole column. For example, .offset4 moves .span4 over four columns.{{/i}}

4
4 offset 4
3 offset 3
3 offset 3
6 offset 6
<div class="row">
  <div class="span4">...</div>
  <div class="span4 offset4">...</div>
</div>

{{_i}}Nesting columns{{/i}}

{{_i}}To nest your content with the default grid, add a new .row and set of .span* columns within an existing .span* column. Nested rows should include a set of columns that add up to the number of columns of its parent.{{/i}}

{{_i}}Level 1 column{{/i}}
{{_i}}Level 2{{/i}}
{{_i}}Level 2{{/i}}
<div class="row">
  <div class="span9">
    {{_i}}Level 1 column{{/i}}
    <div class="row">
      <div class="span6">{{_i}}Level 2{{/i}}</div>
      <div class="span3">{{_i}}Level 2{{/i}}</div>
    </div>
  </div>
</div>

{{_i}}Fixed layout{{/i}}

{{_i}}Provides a common fixed-width (and optionally responsive) layout with only <div class="container"> required.{{/i}}

<body>
  <div class="container">
    ...
  </div>
</body>

{{_i}}Fluid layout{{/i}}

{{_i}}Create a fluid, two-column page with <div class="container-fluid">—great for applications and docs.{{/i}}

<div class="container-fluid">
  <div class="row">
    <div class="span2">
      <!--{{_i}}Sidebar content{{/i}}-->
    </div>
    <div class="span10">
      <!--{{_i}}Body content{{/i}}-->
    </div>
  </div>
</div>
{{! Enabling }}

{{_i}}Enabling responsive features{{/i}}

{{_i}}Responsive CSS requires the following meta tag in the <head> of your pages.{{/i}}

<meta name="viewport" content="width=device-width, initial-scale=1.0">
{{! About }}

{{_i}}About responsive Bootstrap{{/i}}

Responsive devices

{{_i}}Media queries allow for custom CSS based on a number of conditions—ratios, widths, display type, etc—but usually focuses around min-width and max-width.{{/i}}

  • {{_i}}Modify the width of column in our grid{{/i}}
  • {{_i}}Stack elements instead of float wherever necessary{{/i}}
  • {{_i}}Resize headings and text to be more appropriate for devices{{/i}}

{{_i}}Use media queries responsibly and only as a start to your mobile audiences. For larger projects, do consider dedicated code bases and not layers of media queries.{{/i}}

{{! Supported }}

{{_i}}Supported devices{{/i}}

{{_i}}Bootstrap supports a handful of media queries to help make your projects more appropriate on different devices and screen resolutions. Here's what's included:{{/i}}

{{_i}}Label{{/i}} {{_i}}Layout width{{/i}} {{_i}}Column width{{/i}} {{_i}}Gutter width{{/i}}
{{_i}}Large display{{/i}} 1200px and up 70px 30px
{{_i}}Default{{/i}} 980px and up 60px 20px
{{_i}}Portrait tablets{{/i}} 768px and above 42px 20px
{{_i}}Phones to tablets{{/i}} 767px and below {{_i}}Fluid columns, no fixed widths{{/i}}
{{_i}}Phones{{/i}} 480px and below {{_i}}Fluid columns, no fixed widths{{/i}}
/* {{_i}}Large desktop{{/i}} */
@media (min-width: 1200px) { ... }

/* {{_i}}Portrait tablet to landscape and desktop{{/i}} */
@media (min-width: 768px) and (max-width: 979px) { ... }

/* {{_i}}Landscape phone to portrait tablet{{/i}} */
@media (max-width: 767px) { ... }

/* {{_i}}Landscape phones and down{{/i}} */
@media (max-width: 480px) { ... }
{{! Responsive utility classes }}

{{_i}}Responsive utility classes{{/i}}

{{_i}}For faster mobile-friendly development, use these utility classes for showing and hiding content by device. Below is a table of the available classes and their effect on a given media query layout (labeled by device). They can be found in responsive.less.{{/i}}

{{_i}}Class{{/i}} {{_i}}Phones 767px and below{{/i}} {{_i}}Tablets 979px to 768px{{/i}} {{_i}}Desktops Default{{/i}}
.visible-phone {{_i}}Visible{{/i}}
.visible-tablet {{_i}}Visible{{/i}}
.visible-desktop {{_i}}Visible{{/i}}
.hidden-phone {{_i}}Visible{{/i}} {{_i}}Visible{{/i}}
.hidden-tablet {{_i}}Visible{{/i}} {{_i}}Visible{{/i}}
.hidden-desktop {{_i}}Visible{{/i}} {{_i}}Visible{{/i}}

{{_i}}When to use{{/i}}

{{_i}}Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation. Responsive utilities should not be used with tables, and as such are not supported.{{/i}}

{{_i}}Responsive utilities test case{{/i}}

{{_i}}Resize your browser or load on different devices to test the above classes.{{/i}}

{{_i}}Visible on...{{/i}}

{{_i}}Green checkmarks indicate that class is visible in your current viewport.{{/i}}

  • {{_i}}Phone{{/i}}✔ {{_i}}Phone{{/i}}
  • {{_i}}Tablet{{/i}}✔ {{_i}}Tablet{{/i}}
  • {{_i}}Desktop{{/i}}✔ {{_i}}Desktop{{/i}}

{{_i}}Hidden on...{{/i}}

{{_i}}Here, green checkmarks indicate that class is hidden in your current viewport.{{/i}}

  • {{_i}}Phone{{/i}}✔ {{_i}}Phone{{/i}}
  • {{_i}}Tablet{{/i}}✔ {{_i}}Tablet{{/i}}
  • {{_i}}Desktop{{/i}}✔ {{_i}}Desktop{{/i}}
{{! /span9 }}
{{! row}}
{{! /.container }}