Bootstrap is a free, open source framework built with HTML, CSS, and JS to develop responsive web design. It offers an extremely powerful framework developed to facilitate faster and easier web development.
A Little Bit of History
Bootstrap was developed by Mark Otto and Jacob Thornton of Twitter and as the pair wanted to avoid the inconsistencies involved in the creation of internal tools. Previously, there was no set of code structure used by the various teams within Twitter, and this led the company to develop the framework originally known as 'Twitter Blueprint'. This standard could be used seamlessly across the company by all developers when they built new tools.
In 2011, Twitter Blueprint was released as Bootstrap, an open source project on GitHub. Since then, it has been maintained by Mark Otto and Jacob Thornton, as well as a large community of open source developers.
In 2012, Bootstrap 2 was released with the 12 columns grid layout and lots of reusable components.
In 2013, Bootstrap 3 was released with a flat design and supported mobile first design.
In this post, we will explain how to use Bootstrap in an ASP.net MVC app.
Install Using Nuget
Bootstrap is available by default with Visual Studio 2013 and ASP.Net MVC 5. There is a Nuget package available for bootstrap (I have version 3.0.0 installed).
You can also manually download the Bootstrap from here. Extract the files and you should see the following folder structure of the extracted zip.
Install Using Bower
$ bower install bootstrap
Install Using npm
$ npm install bootstrap
About the Grid
Using the Bootstrap Grid system, we can easily create the page layout structure. With Bootstrap 3, it is possible to create a dynamic and responsive page layout and it scales around 12 columns based on different devices such as desktops, tablets, or cellphones.
Bootstrap provides different classes for each type of devices. Below is the prefix of the classes used for different type of devices:
Extra small devices (Cell Phones)
Small Devices (Tablets)
Medium Devices (Laptops)
Large Devices (Desktops)
Now, let’s say we want to create a page layout with 2 columns. Our div structure would look something like this:
<div class="container"> <div class="row"> <div >Row 1 Column 1</div> <div > Row 1 Column 2</div> </div> <div class="row"> <div> Row 2 Column 1</div> <div> Row 2 Column 2</div> </div> </div>
So, if we use the class prefix as .col-xs- for each column div, Bootstrap will apply the style not only for extra small devices but also for small, medium, and large devices too—which is pretty neat.
Now, if we want to show columns side by side in Bootstrap, we have to mark the div styles as per devices to be supported. For demo purposes, we will have this supported for all device types and so we will use the class prefix as .col-xs-*. Also, since Bootstrap supports 12 columns in layout, * in the class has to be replaced with a number less than 12 and all the columns prefix (*) total in the particular row should be 12.
<div class="container"> <div class="row"> <div class="col-sm-6">Row 1 Column 1</div> <div class="col-sm-6"> Row 1 Column 2</div> </div> <div class="row"> <div class="col-sm-3"> Row 2 Column 1</div> <div class="col-sm-9"> Row 2 Column 2</div> </div> </div>
So, in this case, the first row will have two columns of width in ratio 1:1 and the second row will have columns in the ratio of 3:9. In this way, we can create the page layout with 12 columns supported using Bootstrap.
The following tools are very useful for developers to build User Interface for applications using Bootstrap. You can leave the wire framing tool behind and instead use one of these:
1. JetStrap – this is a premier interface building tool for Bootstrap. It is 100% web based with a variety of code snippets available and you can use complex components quickly. You can drag and drop the elements, create a responsive design, and can create one free project with unlimited screens.
2. Brix – This is also 100% web based and provides various ready-to-use templates in addition to the reusable components. You can select one of the templates and start customizing as per your needs. The live testing feature is very useful on this site.
3. Bootsnipp – Bootsnipp provides you with a web based tool for creating bootstrap screens. In addition to the templates, it also provides various forms which are commonly used in applications like Login, Registration, Contact, etc. It also has a very responsive editable grid and various email templates.
Bootstrap Made Web Development Easy!
With Bootstrap, web development with responsive design is so much easier. With Microsoft providing support for Bootstrap directly within Visual Studio, its popularity has grown over the last year and has been very helpful to a lot of people:
1. One framework for all devices – With Bootstrap responsive design you can provide your webpage with support for different devices.
2. Browser support – Bootstrap works with all modern browsers like Mozilla Firefox, Google Chrome, Safari, Internet Explorer, and Opera. You can find more information on browser support over here.
3. Quick to start – With the framework already in place, developers can jump straight into development with the available bootstrap templates
5. Open Source – It is free to use and is supported and backed by a large community of developers.