Web Development Lesson Nine
Web Development Lesson Nine
LESSON NINE
Bootstrap
● What is Bootstrap
● Bootstrap Environment Setup
● Bootstrap Containers
● Bootstrap Grid layout
What is a Bootstrap?
Bootstrap is a free front-end CSS framework for faster and
easier web development, it gives you the ability to easily
create responsive designs.
Bootstrap History
Bootstrap was developed by Mark Otto and Jacob Thornton at Twitter, and
released as an open source product in August 2011 on GitHub.
What is a Bootstrap?
Easy to use: Anybody with just basic knowledge of HTML and CSS can start using
Bootstrap.
Responsive features: Bootstrap's responsive CSS adjusts to phones, tablets, and desktops.
Mobile-first approach: In Bootstrap, mobile-first styles are part of the core framework
Browser compatibility: Bootstrap 4 is compatible with all modern browsers (Chrome,
Firefox, Internet Explorer 10+, Edge, Safari, and Opera)
Bootstrap Environment Setup
A quick way to add bootstrap to your project is to;
● download Bootstrap from getbootstrap.com or
● copy and paste the following codes in your html <head> tag
Grid Classes
<!-- personalise the column width, and how they should appear on
different devices -->
<div class="row">
<div class="col-*-*"></div>
<div class="col-*-*"></div>
</div>
<!-- Or let Bootstrap automatically handle the layout -->
<div class="row">
<div class="col"></div>
<div class="col"></div>
<div class="col"></div>
</div>
Bootstrap Grid Layout
(explaining the bootstrap structure from the previous slide)
First example: create a row (<div class="row">). Then, add the desired
number of columns (tags with appropriate .col-*-* classes). The first star
(*) represents the responsiveness: sm, md, lg or xl, while the second
star represents a number, which should add up to 12 for each row.
Second example: instead of adding a number to each col, let bootstrap
handle the layout, to create equal width columns: two "col" elements =
50% width to each col. three cols = 33.33% width to each col. four cols =
25% width, etc. You can also use .col-sm|md|lg|xl to make the columns
responsive.
Bootstrap Grid Layout
<div class="container-fluid">
<h1>Three equal width columns</h1>
<div class="row">
<div class="col" style="background-color:lavender;">.col</div>
<div class="col" style="background-color:orange;">.col</div>
<div class="col" style="background-color:lavender;">.col</div>
</div>
<h1>Responsive Columns</h1>
<div class="row">
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
<div class="col-sm-3" style="background-color:lavenderblush;">.col-sm-3</div>
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
<div class="col-sm-3" style="background-color:lavenderblush;">.col-sm-3</div>
</div>
<h1>Two Unequal Responsive Columns</h1>
<div class="row">
<div class="col-sm-4" style="background-color:lavender;">.col-sm-4</div>
<div class="col-sm-8" style="background-color:lavenderblush;">.col-sm-8</div>
</div>
</div>
Bootstrap Grid Layout