Intoduction To Bootstrap
Intoduction To Bootstrap
DBAV
Introduction to Bootstrap
Week 02.
SOFTWARE CLUSTER
[ CDEV • Coding and Development Project] [ DBAV • Database Applicati on Development ]
Objectives
4
What is Bootstrap?
• Easy to use: all you need is basic knowledge of HTML and CSS
• Including the externally hosted CSS and JavaScript links in your HTML
files via CDN (Content Delivery Network)
• Include the Bootstrap CSS and Javascript files in the HTML by adding
the following codes inside the <head> element:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
• Now, add the following codes in the <body> element to see how a
full width container looks like with the .container-fluid class
<div class="container-fluid">
<h1>My First Bootstrap Page</h1>
<p>This part is inside a .container-fluid class.</p>
<p>The .container-fluid class provides a full width container.</p>
</div>
.container-fluid provides a
responsive full width container
• Refresh the web page again, you should see 4 columns created in the
page
• Resize your browser, you should see that the columns resize
accordingly too
TEMASEK POLYTECHNIC I School of Informati cs & IT
Grid Classes
.col-sm-3 the columns will stack .col-sm-3 there are 12 columns in a row, by
on top of each other when the putting -3, it means the columns are grouped
screen width is lesser than 576px in 3s, we have 4 columns of 3s here, so 4 * 3
(sm-small devices) = 12 columns in total
• Text colors
• some classes for text colors are: .text-muted , .text-primary , .text-
warning , .text-danger
• Add the following codes to bootstrap_example.html
<p class="text-muted">This text is muted.</p>
<p class="text-primary">This text is primary.</p>
<p class="text-warning">This text represents a warning.</p>
<p class="text-danger">This text represents danger.</p>
• Background colors
• some classes for background colors are: .bg-primary , .bg-secondary ,
.bg-warning , .text-danger
• Add the following codes to bootstrap_example.html
<p class="bg-primary text-white">This bg is primary.</p>
<p class="bg-secondary text-white">This bg is secondary.</p>
<p class="bg-warning text-white">This bg is warning.</p>
<p class="bg-danger text-white">This bg is danger.</p>
.badge creates the badge .badge-secondary determines the color of the bage
27
Modal
• The code above creates the modal dialog (the popup dialog box)
• The code above creates the modal header, click on the “Open
Modal” button to view the modal
× creates the “x” sign
in the button
• The code above creates the modal footer with a red close button
35
Navbar
<body>
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<!-- Brand/logo -->
<a class="navbar-brand" href="#">Logo</a>
</nav>
</body>
.navbar-brand highlights the
brand/logo/name of your page
• To add links inside the navbar, use a <ul> element with class="navbar-
nav". Then add <li> elements with a .nav-item class followed by an <a>
element with a .nav-link class
TEMASEK POLYTECHNIC I School of Informati cs & IT 39
Navbar
• This button will only appear when the width of the screen decreases
to lesser than 576px
• Next, we need to create a <div> and place the links to be inside this
<div>
<!-- Links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
.
.
.
.
</ul>
</div>
• Now, you can refresh the web page again, resize your browser to see
the collapsible navbar