Twitter Bootstrap Layout tutorial
Introduction
In this tutorial, you will learn how to use Twitter Bootstrap toolkit to create Fixed as well as fluid Layouts. The tutorial is based on Twitter Bootstrap Version 2.0, which is the latest version of Twitter Bootstrap as of this writing.
In version 2.0 Twitter Bootstrap has added a responsive feature for phone, tablet portrait, table landscape and small desktops, and large wide screen desktops.
You may make a layout responsive by adding bootstrap-responsive.css file (located under docs\assets\css) into the page.
Twitter Bootstrap Fixed Layout
If you want it create a web page or app layout based on fixed number of pixels, go for this.
Usage
Explanation
From line number 261 to 273 of bootstrap.css (located under docs\assets\css of main twitter bootstrap folder) styles for creating the main container to create a fixed layout is available. The purpose of the Fixed Layout is to create a 940 pixel (default) wide layout for a web page or app.
Example of Fixed Layout with Twitter Bootstrap
The following code creates a Fixed Layout of a webpage. Besides default styles, for customization, a new css example-fixed-layout.css is created and placed in the same folder where bootstrap.css resides.
CSS code
HTML code
View Online
View the above example in a different browser window.
Twitter Bootstrap Fluid Layout
Want to create a layout which is not fixed, instead of based on percentages to keep it flexible, you may go for this.
Usage
Explanation
From line number 274 to 285 of bootstrap.css (located under docs\assets\css of the main twitter bootstrap folder) styles for creating the main container to create a fluid layout is available. The purpose of the fluid Layout is to create a percentage based (e.g. width=20%) layout.
Example of Fluid Layout with Twitter Bootstrap
The following code creates a Fluid Layout of a webpage. Besides default styles, for customization, a new css example-fluid-layout.css is created and placed in the same folder where bootstrap.css resides.
CSS Code:
HTML Code:
View Online
View the above example in a different browser window
You may download all the HTML, CSS, JS and image files used in our tutorials here.
Previous: Twitter Bootstrap Grid System tutorial
Next:
Responsive Web Design with Twitter Bootstrap