Bootstrap 3 tutorial. If you have not used BootStrap so far, or more than that – have not heard about it – I would recommend you take a closer look to this framework. The fact is that this is really a great choice for those who appreciate the convenience and speed of website development. Today I will tell you about how to create a responsive template using BootStrap 3, which will include elements such as: two navigational menus, slider, promo block, a variety of content blocks, various form elements and footer. One more important moment – in this template, we do not use images, it means that our result is focused on speed.
What does the “Responsiveness” mean?
Responsive Web design is a Web design approach aimed at crafting sites to provide an optimal viewing experience – easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from mobile phones to desktop computer monitors).
A site designed with Responsive Web design adapts the layout to the viewing environment by using fluid, proportion-based grids, flexible images, CSS3 media queries, an extension of the @media rule.
- The fluid grid concept calls for page element sizing to be in relative units like percentages, rather than absolute units like pixels or points.
- Flexible images are also sized in relative units, so as to prevent them from displaying outside their containing element.
- Media queries allow the page to use different CSS style rules based on characteristics of the device the site is being displayed on, most commonly the width of the browser.
Preview:

Step 1. HTML
Before you start experimenting with BootStrap framework, let’s prepare a basic html model:
index.html
04 | < meta charset = "utf-8" /> |
05 | < meta name = "author" content = "Script Tutorials" /> |
06 | < meta name = "description" content = "Responsive Websites Using BootStrap - demo page" > |
07 | < meta http-equiv = "X-UA-Compatible" content = "IE=Edge" /> |
08 | < meta name = "viewport" content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" > |
09 | < title >Responsive Websites Using BootStrap | Script Tutorials</ title > |
11 | < link href = "css/bootstrap.min.css" rel = "stylesheet" > |
12 | < link href = "css/style.css" rel = "stylesheet" > |
18 | < script src = "js/bootstrap.min.js" ></ script > |
This is the minimal layout which enables the responsive nature of Twitter Bootstrap. In the header we included all the important meta tags and two CSS files, before the closing body, we added both: jQuery and the minimized bootstrap core. This speeds up the loading of the page. Now we can begin with every element of the page.
This menu is in the very top: this is fixed navigation bar. Here is the markup:
02 | < div class = "navbar navbar-fixed-top navbar-inverse" role = "navigation" > |
03 | < div class = "container" > |
04 | < div class = "navbar-header" > |
05 | < button type = "button" class = "navbar-toggle" data-toggle = "collapse" data-target = "#b-menu-1" > |
06 | < span class = "sr-only" >Toggle navigation</ span > |
07 | < span class = "icon-bar" ></ span > |
08 | < span class = "icon-bar" ></ span > |
09 | < span class = "icon-bar" ></ span > |
11 | < a class = "navbar-brand" href = "#" >Bootstrap website</ a > |
13 | < div class = "collapse navbar-collapse" id = "b-menu-1" > |
14 | < ul class = "nav navbar-nav navbar-right" > |
15 | < li class = "active" >< a href = "#" >Menu 1</ a ></ li > |
16 | < li >< a href = "#" >Menu 2</ a ></ li > |
17 | < li >< a href = "#" >Menu 3</ a ></ li > |
19 | < a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" >< span class = "glyphicon glyphicon-user" ></ span >< b class = "caret" ></ b ></ a > |
20 | < ul class = "dropdown-menu" > |
21 | < li >< a href = "#" >Option 1</ a ></ li > |
22 | < li >< a href = "#" >Option 2</ a ></ li > |
23 | < li >< a href = "#" >Option 3</ a ></ li > |
Generally, it consists of three parts: the hidden button (for mobile device to open the menu), navbar-brand (brand/title) element, and UL-LI-based drop-down menu.
Slider
Right after the top menu, there is the slider: the carousel which turns its items. Its layout is quite familiar:
02 | < div id = "slider" class = "carousel slide" data-ride = "carousel" > |
04 | < ol class = "carousel-indicators" > |
05 | < li data-target = "#slider" data-slide-to = "0" class = "active" ></ li > |
06 | < li data-target = "#slider" data-slide-to = "1" ></ li > |
07 | < li data-target = "#slider" data-slide-to = "2" ></ li > |
09 | < div class = "carousel-inner" > |
11 | < div class = "item active" > |
12 | < div class = "container" > |
13 | < div class = "carousel-caption" > |
14 | < h1 >Lorem ipsum - 1</ h1 > |
15 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi.< br />Sed sed volutpat neque. Nulla posuere.</ p > |
16 | < p >< a class = "btn btn-lg btn-default" href = "#" role = "button" >Button 1</ a ></ p > |
21 | < div class = "container" > |
22 | < div class = "carousel-caption" > |
23 | < h1 >Lorem ipsum - 2</ h1 > |
24 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi.< br />Sed sed volutpat neque. Nulla posuere.</ p > |
25 | < p >< a class = "btn btn-lg btn-primary" href = "#" role = "button" >Button 2</ a ></ p > |
30 | < div class = "container" > |
31 | < div class = "carousel-caption" > |
32 | < h1 >Lorem ipsum - 3</ h1 > |
33 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi.< br />Sed sed volutpat neque. Nulla posuere.</ p > |
34 | < p >< a class = "btn btn-lg btn-warning" href = "#" role = "button" >Button 3</ a ></ p > |
40 | < a class = "left carousel-control" href = "#slider" data-slide = "prev" >< span class = "glyphicon glyphicon-chevron-left" ></ span ></ a > |
41 | < a class = "right carousel-control" href = "#slider" data-slide = "next" >< span class = "glyphicon glyphicon-chevron-right" ></ span ></ a > |
The familiar – this is because it contains quite usual elements: the ability to switch slides (indicators), the buttons back and forth, and the slides themselves.
Modal box
Modal boxes are quite an important part of the user interface, so we’ll create one modal box:
02 | < div class = "modal fade" id = "my-modal-box" tabindex = "-1" role = "dialog" aria-labelledby = "my-modal-box-l" aria-hidden = "true" > |
03 | < div class = "modal-dialog" > |
04 | < div class = "modal-content" > |
05 | < div class = "modal-header" > |
06 | < button type = "button" class = "close" data-dismiss = "modal" aria-hidden = "true" >×</ button > |
07 | < div class = "modal-title" id = "my-modal-box-l" > |
11 | < div class = "modal-body" > |
12 | < p >Share it box content</ p > |
Finally we come to the main point – the main container which consists of the second navigation menu, footer and additional content blocks. The second menu is not fixed, this is a similar UL-LI-based menu, but the most right element calls the pre-made modal box:
02 | < nav class = "navbar navbar-default navbar-static" > |
03 | < div class = "navbar-header" > |
04 | < button class = "navbar-toggle" type = "button" data-toggle = "collapse" data-target = "#b-menu-2" > |
05 | < span class = "sr-only" >Toggle navigation</ span > |
06 | < span class = "icon-bar" ></ span > |
07 | < span class = "icon-bar" ></ span > |
08 | < span class = "icon-bar" ></ span > |
13 | < div class = "collapse navbar-collapse" id = "b-menu-2" > |
14 | < ul class = "nav navbar-nav" > |
15 | < li class = "active" >< a href = "#" >< span class = "glyphicon glyphicon-home" ></ span > Home</ a ></ li > |
16 | < li >< a href = "#" >< span class = "glyphicon glyphicon-question-sign" ></ span > Help</ a ></ li > |
17 | < li >< a href = "#" >< span class = "glyphicon glyphicon-exclamation-sign" ></ span > About</ a ></ li > |
19 | < a href = "#" class = "dropdown-toggle" data-toggle = "dropdown" >< span class = "glyphicon glyphicon-list" ></ span > Other < b class = "caret" ></ b ></ a > |
20 | < ul class = "dropdown-menu" > |
21 | < li >< a href = "#" >Submenu 1</ a ></ li > |
22 | < li >< a href = "#" >Submenu 2</ a ></ li > |
23 | < li >< a href = "#" >Submenu 3</ a ></ li > |
24 | < li >< a href = "#" >Submenu 4</ a ></ li > |
25 | < li class = "divider" ></ li > |
26 | < li >< a href = "#" >Submenu 5</ a ></ li > |
27 | < li >< a href = "#" >Submenu 6</ a ></ li > |
28 | < li class = "divider" ></ li > |
29 | < li >< a href = "#" >Submenu 7</ a ></ li > |
33 | < ul class = "nav navbar-nav navbar-right" > |
34 | < li data-toggle = "modal" data-target = "#my-modal-box" >< a href = "#" >< span class = "glyphicon glyphicon-share" ></ span > Share popup</ a ></ li > |
Two column layout with blocks
This section is quite huge, but it is rather simple: blocks are repeated. Just pay attention to my comments:
002 | < div class = "row row-offcanvas row-offcanvas-right" > |
003 | < div class = "col-xs-12 col-sm-9" > |
005 | < div class = "jumbotron" > |
007 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
008 | < p >< a role = "button" href = "#" class = "btn btn-lg btn-success" >Sign up today</ a ></ p > |
012 | < div class = "col-sm-6" > |
014 | < div class = "panel panel-default" > |
015 | < div class = "panel-heading" > |
016 | < h3 class = "panel-title" >Panel 1 title</ h3 > |
018 | < div class = "panel-body" > |
019 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
020 | < p >< a class = "btn btn-default right" href = "#" role = "button" >Continue »</ a ></ p > |
024 | < div class = "panel panel-primary" > |
025 | < div class = "panel-heading" > |
026 | < h3 class = "panel-title" >Panel 2 title</ h3 > |
028 | < div class = "panel-body" > |
029 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
030 | < p >< a class = "btn btn-default right" href = "#" role = "button" >Continue »</ a ></ p > |
035 | < div class = "col-sm-6" > |
037 | < div class = "panel panel-success" > |
038 | < div class = "panel-heading" > |
039 | < h3 class = "panel-title" >Panel 3 title</ h3 > |
041 | < div class = "panel-body" > |
042 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
043 | < p >< a class = "btn btn-default right" href = "#" role = "button" >Continue »</ a ></ p > |
047 | < div class = "panel panel-warning" > |
048 | < div class = "panel-heading" > |
049 | < h3 class = "panel-title" >Panel 4 title</ h3 > |
051 | < div class = "panel-body" > |
052 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
053 | < p >< a class = "btn btn-default right" href = "#" role = "button" >Continue »</ a ></ p > |
060 | < div class = "col-sm-3 sidebar-offcanvas" id = "sidebar" > |
061 | < div class = "list-group" role = "navigation" > |
062 | < a href = "#" class = "list-group-item" >Link</ a > |
063 | < a href = "#" class = "list-group-item" >Link</ a > |
064 | < a href = "#" class = "list-group-item active" >Link</ a > |
065 | < a href = "#" class = "list-group-item" >Link</ a > |
066 | < a href = "#" class = "list-group-item" >Link</ a > |
069 | < div class = "panel panel-danger" > |
070 | < div class = "panel-heading" > |
071 | < h3 class = "panel-title" >Form elements</ h3 > |
073 | < div class = "panel-body" > |
075 | < div class = "form-group" > |
076 | < label for = "emailField" >Email address</ label > |
077 | < input type = "email" class = "form-control" id = "emailField" placeholder = "Enter email" > |
079 | < div class = "form-group" > |
080 | < label for = "selectField" >Type</ label > |
081 | < select class = "form-control" id = "selectField" > |
089 | < div class = "progress progress-striped active" > |
090 | < div class = "progress-bar progress-bar-success" role = "progressbar" aria-valuenow = "40" aria-valuemin = "0" aria-valuemax = "100" style = "width:30%" > |
091 | < span class = "sr-only" >30% Complete</ span ></ div > |
093 | < button type = "submit" class = "btn btn-default" >Submit</ button > |
098 | < div class = "panel panel-info" > |
099 | < div class = "panel-heading" > |
100 | < h3 class = "panel-title" >Panel 6 title</ h3 > |
102 | < div class = "panel-body" > |
103 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
104 | < p >< a class = "btn btn-default right" href = "#" role = "button" >Continue »</ a ></ p > |
In the beginning, the whole layout is divided into two columns, but then, the first column is split to another two columns. In the first column, there is the ‘jumbotron’ element, which you can use to put some introduction in there. As I remarked before – all blocks are very similar, here is the markup of the basic block:
1 | < div class = "panel panel-default" > |
2 | < div class = "panel-heading" > |
3 | < h3 class = "panel-title" >Panel 1 title</ h3 > |
5 | < div class = "panel-body" > |
6 | < p >Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sit amet tempus massa. Nam quis purus sit amet augue iaculis dapibus non in nisi. Sed sed volutpat neque. Nulla posuere.</ p > |
7 | < p >< a class = "btn btn-default right" href = "#" role = "button" >Continue »</ a ></ p > |
In order to change it’s color, you may change its class (panel-default) to one of the following: panel-primary, panel-success, panel-info, panel-warning or panel-danger.
There is only one unexplained element – footer
2 | < nav class = "navbar navbar-default navbar-static-bottom" role = "navigation" > |
3 | < p class = "navbar-text" >© Copyright 2013</ p > |
Step 2. CSS
By and large – all the things that we’ve created – does not require special styles. Most of possible elements are already defined in BootStrap stylesheet file (bootstrap.min.css). However, there is only one customized element – the slider (carousel):
css/style.css
09 | background-color : rgba( 0 , 0 , 0 , 0.8 ); |
[sociallocker]
[/sociallocker]
Conclusion
In the process of learning the BootStrap framework, we have come to an end. Basically, we only prepared the necessary layout of the page, all the rest has done by this framework. Wonderful, is not it? Thank you for reading this tutorial. Don’t hesitate to share it with your friends using the form below.