Bootstrap
Bootstrap
4
Bootstrap Essentials
5
Including Bootstrap
• There are different ways to include Bootstrap framework
files into your pages:
1. Download and host the Bootstrap files.
2. Include Bootstrap from a CDN (Content Delivery
Network) host. This is faster and easier option for our
course.
• To apply the second way, include in the following code in
your header:
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
6
Bootstrap Features
7
Containers
8
Grid System
• The Bootstrap Grid System visualizes the webpage into a
series of rows and columns, i.e. a grid.
9
Applying the Columns
• Single Rows use the class row.
• All columns inside a row are use the class form: col-xx-y.
Where xx is the intended size (xs, sm, md, lg) and y is a
column span size (from 1 to 12).
<div class="container">
<!--Row wi t h two equal columns-->
<div class="row">
<div class="col-md-6"><!--Column l e f t - - > < / d i v >
<div class="col-md-6"><!--Column r i g h t - - > < / d i v >
</div>
10
Grid System
XS, SM, M D and LG
Grid behaviour Horizontal at all times Collapsed to start, Collapsed to start, Collapsed to start,
horizontal above horizontal above horizontal above
breakpoints breakpoints breakpoints
Container width None (auto) 750px 970px 1170px
Class prefix .col-xs- .col-sm- .col-md- .col-lg-
Column width Auto ~62px ~81px ~97px
Gutter width 30px (15px on each side of a column)
11
Grid System - lg
Large
12
Grid System - md
Medium
13
Grid System –sm & xs
Small X-Small
14
Combining Grid Classes
15
Combining Grid Classes
16
Grid Offset
<div class="row">
<div class="col-md-6 col1">.col-md-6</div>
<div class="col-md-5 col-md-offset-1">.col-md-5 and o f f s e t - 1 < / d i v >
</div>
17
Visible or Hidden Element
18
Navigation
Navigation Bar
20
Dropdown Links Menu
21
Dropdown Links Menu
< l i class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Page 1 - 1 < / a ></ l i >
<li><a href="#">Page 1 - 2 < / a ></ l i >
<li><a href="#">Page 1 - 3 < / a ></ l i >
</ul>
</li>
22
Table
<div class="container">
<table c l a s s =" t a bl e table-bordered">
<thead> < t r >
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr></thead>
<tbody>
<tr>
<td>John</td> <table class="table table-striped">
<td>Doe</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>[email protected]</td>
</ t r >
< / t b ody>
</ t a ble > <table class="table">
</div>
23
Image
<div class="container">
<img s r c = " c i n q u e t e r r e . j p g " class="img-rounded" alt="Cinque Terre"
width="304" height="236">
</div>
24
Alert
<div class="container">
<h2>Alerts</h2>
<div c l a s s = " a l e r t alert -success ">
<strong>Success!</strong> This a l e r t box
could i n d i c a t e a successful or p o s i t i v e
action.
</div>
<div c l a s s = " a l e r t a l e r t - i n f o " >
<strong>Info!</strong> This a l e r t box could
i n d i c a t e a n e u t r a l i n f o r ma t i ve change o r
action.
</div>
<div c l a s s = " a l e r t a l e r t - wa r n i n g " >
<strong>Warning!</strong> This a l e r t box
could i n d i c a t e a warning t h a t might need
attention.
</div>
<div c l a s s = " a l e r t al er t - dang er ">
<strong>Danger!</strong> This a l e r t box
could i n d i c a t e a dangerous o r p o t e n t i a l l y
negative a c t i o n .
</div>
</div>
25
Button
<div class="container">
<h2>Button Styles</h2>
<button type="button" class="btn">Basic</button>
<button type="button" class=" btn b t n - defa ult " >Defa ul t</butto n>
<button type="button" class=" btn btn-primary">Primary</button>
<button type="button" class=" btn btn-success">Success</button>
<button type="button" class=" btn b t n - i n f o " > I n f o < / b u t t o n >
<button type="button" class=" btn btn-warning">Warning</button>
<button type="button" class=" btn btn-danger">Danger</button>
<button type="button" class=" btn b t n - l i n k " > L i n k </ b u t t o n >
</div>
26
Glyphicon
<div class="container">
<h2>Glyphicon Examples</h2>
<p>Envelope i c o n : <span class="glyphicon glyphicon-envelope"></span></p>
<p>Envelope icon as a l i n k :
<a href="#"><span class="glyphicon glyphicon-envelope"></span></a>
</p>
<p>Search i c o n : <span class="glyphicon glyphicon-search"></span></p>
<p>Search icon on a b u t t o n :
<button type="button" class="btn b t n - d e f a u l t " >
<span class="glyphicon glyphicon-search"></span> Search
</button>
</p>
<p>Search icon on a s t yl e d b u t t o n :
<button type="button" class="btn b t n - i n f o " >
<span class="glyphicon glyphicon-search"></span> Search
</button>
</p>
<p>Print i c o n : <span class="glyphicon glyphicon-print"></span></p>
<p>Print icon on a s t yl e d l i n k b u t t o n :
<a h r e f =" # " class="btn btn-success b t n - l g " >
<span class="glyphicon glyphicon-print"></span> P r i n t
</a>
</p>
< / d iv> 26
Badge
?
<button type="button" class="btn btn-primary">
Primary <span class="badge">7</span></button>
28
More components
• Use the resources listed on the first slide to learn more
about Bootstrap components and features. Particularly
the official Bootstrap and W3 Schools websites.
Typography
29
More resources…
https://startbootstrap.com/
Free Bootstrap Themes & Templates
https://bootstrapbay.com/
High quality Bootstrap themes & templates for
your next web project
30