Lesson 05 Bootstrap
Lesson 05 Bootstrap
There was a time when User Interface (UI) was not a concern.
Introduction to Responsive Web Design (RWD)
Many companies have successfully created excellent designs for their web applications.
Introduction to Responsive Web Design (RWD)
But today, just a unique web application screen is not enough. We need "Responsive Web Design (RWD).
Introduction to Bootstrap
Topic 1—What is Responsive Web Design (RWD)
What Is Responsive Web Design?
A Responsive Web Design is browser-responsive and can adapt to screens of any size.
Responsive vs. Adaptive
A responsive web design is a fluid design that responds to the browser and can
Responsive
resize according to the screen size with no empty spaces on the sides.
Adaptive An adaptive design adapts to the screen size only at specific points.
Relative units like percentages can adapt to any screen, unlike static units such as pixels.
100% 600px
The flow in a responsive web design helps the content to smoothly adjust when the screen size changes,
which does not happen in static screens.
Flow Static
With Breakpoints vs. Without Breakpoints
The presence of breakpoints allows you to adapt your content to the screen size when screen size changes.
With Breakpoints
Without Breakpoints
Vectors vs. Images
A vector adapts to the resolutions of the retina, and its quality is independent of the screen resolution.
Vector Image
Mobile First
Topic 2—Bootstrap 3
Bootstrap
HISTORY
SAAS support
Mobile-first approach
New components
Advantages of Bootstrap 3
Bootstrap 2 to Bootstrap 3
Competitors
VS.
VS.
Grid system
Responsive utilities
Use of @media Rule
With @media rule in Bootstrap 3, you can have a different layout for all screens, including
tablet, mobile, and desktops.
Introduction to Grid Systems
In Bootstrap 3
• You can group and create wider columns instead of using them individually.
• For decent organization and padding, place the rows within .container-fluid (full-width) or a
.container (fixed-width).
• Create grid columns by specifying the number of available 12 columns you wish to span.
• Place the content within columns, and only columns may be immediate children of rows.
Grid System
In Bootstrap 3, the grid system presents a swift and simple way to build responsive website layouts.
Bootstrap Grid Classes
lg (for larger
xs (for phones) sm (for tablets) md (for desktops)
desktops)
These classes can be combined to create more dynamic and flexible layouts.
Bootstrap Grid Classes
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
Responsive Utilities
• Labels • Badges
• Panels • Dropdowns
• Jumbotron • Button groups
• Page Header • Glyphicons
• Navbar • Button Drops
• Thumbnails • Breadcrumbs
• Alerts • Input groups
• List group • Navs
• Page Header • Pagination
• Wells • Media Object
Step 1: Creating First Page with Bootstrap
At the start of the page, include HTML5 doctype. Also include the lang attribute and the right character set.
<!DOCTYPE html>
<html lang=“pt”>
<head>
<meta charset=“utf-8”>
<meta name=“viewport” content=“width=device-width, initial-scale=1”>
</head>
</html>
Step 2: Creating First Page with Bootstrap
• Add the viewport <meta> tag for proper touch zooming and rendering
• Adjust the width of the page and the initial zoom level per your device
• This will ensure that you have a better experience, and there will be no need for zooming
Step 3: Creating First Page with Bootstrap
o bootstrap.min.css
o jquery.min.js
o bootstrap.min.js
• Download these files and include in your page. In this example, we include them from the Internet:
<link rel=“stylesheet”
href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”>
<script
src=“https://ajax.googleapis.com/ajax/libs/jquesry/3.1.1/jquery.min.js”></script>
<script
src=“https://maxcdn.bootstrapcdn.com/ajax/bootstrap/3.3./js/bootstrap.min.js”></script>
Step 4: Creating First Page with Bootstrap
<div class=“container”>
<h1>My First Bootstrap Page</h1>
<p>this is some text.</p>
</div>
<div class=“container-fluid”>
<h1>My First Bootstrap Page</h1>
<p>This is some text.</p>
</div>
Bootstrap Grids
Example:
• In this example, the space inside the container is divided into a single row and the row is divided into 3
columns.
• Each column has the same sides, that is, 4+4+4 = 12
• Any possible combination that sums up to 12 can be used.
<div class=“container”>
<h1>Bootstrap Grid</h1>
<div class=“row”>
<div class=“col-sm-4”>.col-sm-4</div>
<div class=“col-sm-4”>.col-sm-4</div>
<div class=“col-sm-4”>.col-sm-4</div>
</div>
Bootstrap Grids
Output:
Here is what a responsive grid system in Bootstrap 3 with 3 columns in the page looks like:
There are four main and five contextual classes in Bootstrap 3 tables:
1. .table
Main Classes 2. .table-striped
3. .table-bordered
Contextual Classes
4. .table-hover
Bootstrap Tables
There are four main and five contextual classes in Bootstrap 3 tables:
1. .active
Main Classes 2. .success
3. .info
Contextual Classes
4. .warning
5. .danger
Bootstrap Tables—Example
<div class=“container”>
<h1>Bootstrap Table</h1>
<table class=“table table-stripped table-bordered table-hover”>
<thead>
<tr>
<th>Firstname</th>
<th>lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Joseph</td>
<td>saints</td>
<td>[email protected]</td>
</tr>
<tr class=“warning”>
<td>Mary Help</td>
<td>saints</td>
<td>[email protected]</td>
</tr>
</tbody>
</table>
</div>
Bootstrap Tables—Example
Output:
.img-circle
.img-thumbnail
.img-rounded
1 3
Bootstrap Images—Example
<div class=“row”>
<div class=“col-md-4”>
<img class=“img-rounded” src=“garden-house-hotel-11.jpg”
alt=“Garden” style=“width:100%”>
</div>
<div class=“col-md-4”>
<img class=“img-circle” src=“Xmas-House-5-25*256.jpg” alt=“Snow”
style=“width:100%”>
</div>
<div class=“col-md-4”>
<img class=“img-thumbnail” src=“Accomodation_image.jpg” alt=“beach”
style=“width:100%”>
</div>
</div>
Bootstrap Images
Output:
In Bootstrap 3, you have an easy way to create predefined alert messages using alert
class, followed by one of these contextual classes.
.alert-success .alert-info
.alert-danger .alert-warning
Bootstrap Alerts—Example
<div class=“container”>
<h1>Bootstrap Alerts</h1>
Output:
In Bootstrap 3, there are seven styles of buttons that can be created using these contextual classes:
.btn-primary .btn-success
2 3
.btn-default 1 4 .btn-info
7 5 .btn-warning
.btn-link
.btn-danger
Bootstrap Buttons—Example
<div class=“container”>
<h1>Bootstrap Button</h1>
<button type=“button” class=“btn btn-default”>Default</button>
<button type=“button” class=“btn btn-default”>Primary</button>
<button type=“button” class=“btn btn-default”>Success</button>
<button type=“button” class=“btn btn-default”>Info</button>
<button type=“button” class=“btn btn-default”>Warning</button>
<button type=“button” class=“btn btn-default”>Danger</button>
<button type=“button” class=“btn btn-default”>Link</button>
</div>
Output:
• (http://getbootstrap.com/components/)
Bootstrap Glyphicons—Example
<div class=“container”>
<h1>Bootstrap glyphicon</h1>
<p>simple span:
<span class=“glyphicon glyphicon-check”></span>
</p>
<p>Default button with icon:
<button type=“button” class=“btn btn-default”>Play
<span class=“glyphicon glyphicon-play”></span>
</button>
</p>
<p>search icon on a styled button:
<button type=“button” class=“btn btn-info”>
<span class=“glyphicon glyphicon-search”></span> Search
</bbutton>
</p>
<p>Link with icon:
<a href=“#” class=“btn btn-success btn-lg”>
<span class=“glyphicon glyphicon-print”></span>Print
</a>
</p>
</div>
Bootstrap Glyphicons
Output:
Bootstrap Labels
In Bootstrap 3:
• You can create labels with backgrounds of different colors using the .label class and one of these:
.label-danger .label-default
.label-warning
Contextual .label-primary
Classes
.label-info .label-success
Bootstrap Labels—Example
<div class=“container”>
<h1>Bootstrap Label</h1>
Output:
Default Label Primary Label Success Label Info Label Warning Label Danger Label
Bootstrap Panels
• In Bootstrap 3, a panel is a box with a border and padding around the content.
.panel-danger .panel-default
6
1
. panel-warning 5
2 .panel-primary
4
.panel-info 3 .panel-success
Bootstrap Panels—Example
<div class=“container”>
<h1>Bootstrap Panel</h1>
Output:
Panel Heading
Panel Content
Panel Footer
Bootstrap Themes and Templates
• Both theme and template are a collection of elements like grids, buttons,
and panels that are put together to create a fully functional website/web
application.
• You can download several freely available templates themes.
• Some templates can be downloaded from
https://startbootstrap.com/template-categories/all/
Bootstrap Themes and Templates
SB Admin 2 template is relevant for web applications. It consists of tables, forms, charts, and other components.
Bootstrap Themes and Templates
• Download the SB Admin 2 template on your computer
b. The width of the page to follow the screen-width of the device (which will vary
depending on the device)
b. The width of the page to follow the screen-width of the device (which will vary
depending on the device)
a. True
b. False
QUIZ
We can create badges inside buttons.
3
a. True
b. False
a. lst-group
b. list-group
c. menu-group
d. list-grp
QUIZ
Which class creates a list of items?
4
a. lst-group
b. list-group
c. menu-group
d. list-grp