Professional Documents
Culture Documents
© Copyright by Interviewbit
Contents
Page © Copyright by
Bootstrap Tutorial: Basics to Advanced (
Continued)
21. Sizing - Bootstrap
22. Spacing - Bootstrap
23. Flexbox - Bootstrap
Page © Copyright by
Let's get Started
What is Bootstrap?
Bootstrap is an amazing web design framework that makes it easy to build
responsive websites quickly and easily. Bootstrap was originally developed by
Twitter to get more consistency across websites. Since it was released as an open-
source framework in 2011, it has become one of the most popular web frameworks.
Nowadays, several users are moving away from desktop towards mobile therefore,
a lot of websites need to be responsive.
Now, responsive is probably not the best term for what this means as a lot of
people think that responsiveness means that the website will load up immediately
or it has to be fast but that's not what responsive is at all. Responsiveness just
means that it responds to the viewport. That means if you are looking at the same
website on a mobile or on an iPad it should have a different layout to be able to
best take advantage of the screen.
Now, What does it allow you to do?
Imagine you need a website with an attractive navigation bar, stylish buttons, nice
typography, placeholders for text and images, a slider, and more-yet you aren’t a
front-end developer. But what if these features were already coded for you, and
you just had to write a little HTML to use them? This is Bootstrap. All the
JavaScript code and CSS classes needed are already included in the Bootstrap
package.
For example: If you want a button like this:
Page © Copyright by
Bootstrap Cheat
Then you can incorporate a predefined bootstrap class in your code without the has
Syntax:
Welcome to InterviewBit
<!DOCTYPE html>
<html>
2. Uses of Bootstrap
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1>Hello, world!</h1>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins, or just specific files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
Page 4 © Copyright by
Bootstrap Cheat
Bootstrap has built-in classes, so you don't have to create most elements from
scratch.
It’s open-source.
It's very flexible and can be used to create any type of website in no time at all.
Websites made with bootstrap are faster, more responsive, and mobile-friendly.
Bootstrap supports JavaScript plugins.
3. Features of Bootstrap
Bootstrap is compatible with all modern browsers.
Bootstrap is the 3rd highest starred open project on
GitHub. Bootstrap provides a powerful grid system
Bootstrap provides simple integration
Bootstrap has good community support as well as documentation
documentation
Bootstrap has pre-styled components
Bootstrap is easy to learn and use as anybody with just basic knowledge of
HTML and CSS can start using Bootstrap.
Bootstrap uses a cache system in which we do not have to install it on our
computer. After connecting to the internet once, it makes a cache of its files
and stores them in the web browser.
4. Alerts - Bootstrap
A bootstrap alert is a message sent to users when something goes wrong.
In the case of typos such as incorrect email addresses or credit card numbers,
the user will receive an error alert message that prompts them to make
corrections.
Example:
Page 5 © Copyright by
Bootstrap Cheat
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/boot
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></scri
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></s
</head>
<body>
<div class="container">
<h2>Alerts</h2>
<div class="alert alert-success">
<strong>Success! alert</strong>
</div>
<div class="alert alert-info">
<strong>Info! alert</strong>
</div>
<div class="alert alert-warning">
<strong>Warning! alert</strong>
</div>
<div class="alert alert-danger">
<strong>Danger! alert</strong>
</div>
</div>
</body>
</html>
Page 6 © Copyright by
Bootstrap Cheat
Alert-
For
Success <div class="alert alert-secondary"
successful role InterviewBit
</div>
actions.
Alert-
Danger For warning <div class="alert alert-danger"
role="a InterviewBit
messages. </div>
Page 7 © Copyright by
Bootstrap Cheat
5. Buttons - Bootstrap
Responsive buttons can be built with the latest bootstrap 5.
Example:
PrimarySecondarySuccessDangerWarningInfoLightDarkLink
Page 8 © Copyright by
Bootstrap Cheat
btn- Btn-primary
primary is used to
display
buttons
with a
particular
style for
each class, <button type="button"
for example, class="btn">Interv
primary
displays
buttons
with blue
background.
btn- Btn-
secondary secondary is
used to
displays
buttons <button type="button" class="btn-
with a grey seconda
background.
btn- Btn-success
success displays
button with
green
background. <button type="button" class="btn-
success
Page 9 © Copyright by
Bootstrap Cheat
<button
type="button"
class="btn-
info">I
Page © Copyright by
Bootstrap Cheat
6. Breadcrumb - Bootstrap
Breadcrumbs help users navigate from one page to another without getting lost
and let them return to a previous page if they get lost.
Breadcrumb navigation provides links back to each previous page the user
navigated through and shows the user's current location in a website.
Breadcrum
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item
7. Badges - Bootstrap Breadcrum active"
b is used </ol>
Bootstrap badges are used for adding additional </nav>
information.
for <nav aria-label="breadcrumb">
Example: indicating <ol class="breadcrumb">
<li class="breadcrumb-item"><a
the current href
page's <li class="breadcrumb-item
active"
location </ol>
within a </nav>
<nav aria-label="breadcrumb">
navigation <ol class="breadcrumb">
<li class="breadcrumb-item"><a
href
Page © Copyright by
Bootstrap Cheat
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href=""
<script src="
</head>
<body>
</body>
</html>
Page © Copyright by
Bootstrap Cheat
parent
element.
badge- Badge-pill is
pill used for
making <span class="badge badge-pill badge-
badges ligh
more
rounded.
badge- Badge-
primary primary is
used to add <span class="badge badge-primary">Welcom
a batch to
the primary
message.
badge- Badge-
secondary secondary is
used to add
a batch to <span class="badge badge-badge-secondary
the
secondary
message.
badge- To display a
success badge <span class="badge bg-success">Welcome
indicating t
success.
Page © Copyright by
Bootstrap Cheat
8. Cards - Bootstrap
We have cards in Bootstrap that are simple containers that can hold images and
descriptions. Below are some of the functions associated with a card.
Page © Copyright by
Bootstrap Cheat
card- card-body
body holds the <div class="card-body">InterviewBit</div
content of
the card.
card- Card-title
title holds the <h2 class="card-title">InterviewBit</h2>
title of the
card.
card- Card-
subtitle subtitle is
used for <h6 class="card-subtitle">
InterviewBit</h
adding
subtitles.
card- card-link is
link used for
adding a <a href="#!" class="card-
link">InterviewBi
link to a
card.
Page © Copyright by
Bootstrap Cheat
9. Pagination - Bootstrap
Pagination helps to display the different page numbers of a website. With the help of
paginators, we can jump to any page of the website.
Page © Copyright by
Bootstrap Cheat
Add basic
pagination
<ul class="pagination">
to display <li class="page-item"><a class="page-
only lin
pagination <li class="page-item"><a class="page-
certain lin
<li class="page-item"><a class="page-
records on lin
one page. </ul>
To disable
a
particular
page-item page <li class="page-item disabled">
disabled number or <a class="page-link" href="#!"
tabi
item from
being
clicked.
To
indicate
page-item the <li class="page-item active"><a
active currently class="pa
active
page item.
Display
pagination- larger size <ul class="pagination pagination-lg">
lg pagination
blocks.
Display
smaller
pagination- <ul class="pagination pagination-lg">
size
sm
pagination
blocks.
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
carousel Carousel
slide slide adds
animation <div class="carousel slide" data-
ride="carou
and CSS
transition
effect.
carousel- Carousel-
fade fade is
used to
animate
the slide <div class="carousel slide carousel-fade"
da
transition
with a
crossfade
instead of
a slide.
carousel- Carousel-
inner inner
contains
individual <div class="carousel-inner">
slides to
the
carousel.
carousel- The
item wrapper
class is
applied
to each <div class="carousel-inner">
individual
carousel
item in
the div.
Page © Copyright by
Bootstrap Cheat
<!DOCTYPE html>
<html lang="en">
<head>
<title>collapse in bootstrap</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.mi
</head>
<body>
Page © Copyright by
Bootstrap Cheat
collap
Display
and hide
content
whenever
<p>
Accordi
on <a class="btn btn-primary" data-
Used to
bootstra
Build
vertically
<div id="accordion"> <div
collapsing Item </a> </div> <div
accordions #1 </ </ <div
in
combinatio
n with our
Collapse
JavaScript
plugin.
Page © Copyright by
Bootstrap Cheat
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButto Dropdo
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Bootstrap cheatsheet</a>
<a class="dropdown-item" href="#">Bootstrap 5 cheatsheet</a>
<a class="dropdown-item" href="#">Bootstrap 4 cheatsheet</a>
</div>
</div>
Page © Copyright by
Bootstrap Cheat
dropright dropright
is used to
display the
dropdown <div class="dropdown dropright">
menu on
the right
side.
dropleft dropleft is
used to
display the
dropdown <div class="dropdown dropleft">
menu on
the left
side.
dropdown- Dropdown-
header header is
used to
add <li
head class="dropdown-header">Dropdown
headers
inside the
dropdown
Page © Copyright by
Bootstrap Cheat
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-
describedby="
<small id="emailHelp" class="form-text text-muted">We'll never share your email
wit
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"
placeholder=
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
Page © Copyright by
Bootstrap Cheat
form- When
group added as
a wrapper
around
each input
type or
form <div class="form-group">
control, it
creates a
stacked
form with
proper
margins.
form- All
inline elements
are inline
in the <form class="form-inline"
action="someactio
form
along with
left
margins
form- form-
control control is
the
default
class for
styling <input type="password" class="form-
control"
<input>,
<select>
Page © Copyright by
Bootstrap Cheat
and
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
container container
for the <div class="container">content</div>
grid.
container- fluid
fluid container <div class="container-fluid">full-width
for full- con
width.
row row
<div class="row">
elements ... column elements for the row
of the </div>
grid.
col-# ( a column
<div class="col-2">
<576px) with <div class="col-4">
specified <div class="col-8">
width.
col-sm-# ( small
≥576px) columns
<div class="col-sm-2"> <div class="col-
with sm-
<div class="col-sm-8">
specified
width.
col-md-# (
medium <div class="col-md-2">
≥768px) <div class="col-md-4">
column.
col-lg-# (
<div class="col-lg-2">
≥992px) large <div class="col-lg-4">
column <div class="col-lg-8">
Page © Copyright by
Bootstrap Cheat
Jumbotro Using a
jumbotron
16. Navbar - Bootstrapa big box
<div class="mt-4 p-5 bg-primary text-
was wh
The navigation bar is a header that
created to appears at the top of the page.
<h1>Bootstrap Jumbotron</h1>
The .navbar should be wrapped <p>Lorem ipsum...</p>
in .navbar-expand{-sm|-md|-lg|-xl} for
give focus
responsive collapsing andoncolor
some scheme classes.
Example: special
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
navbar A header is
placed at the
top of a
webpage to <ul class="navbar-nav">
navigate to
different
elements.
navbar- Navbar-brand is
brand used to
highlight a <a class="navbar-brand"
brand, main href="#">Interv
project or logo
of the page.
navbar-
For navbar text. <span class="navbar-text">
text
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/boot
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></scri
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></s
</head>
<body>
<div class="container">
<h2>Basic Table bootstrap 4</h2>
<p>The .table class adds basic styling (light padding and only horizontal dividers) t
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lavish </td>
<td>malik</td>
<td></td>
</tr>
<tr>
<td>John</td>
<td>dellinger</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Page © Copyright by
Bootstrap Cheat
the table
header.
the table
header.
table-
ruled table. <table class="table table-
bordered bordered"
effect on table
rows.
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
border-
*-0 It represents
no border.
Variations –
border-top-0
represents no <span class="p-1 border border-
primary
border on top, <span class="p-1 border border-
primary
in similar way
bottom, right
and left are
possible.
Page © Copyright by
Bootstrap Cheat
rounded- rounded-sm
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
d-*- display
block block <span class="d-block bg-primary">display
block
with a
<span class="d-sm-block bg-success">display
specific sm
styling.
d-*- display
flex flex items <div class="d-flex bg-secondary">...</div>
with a
<span class="d-md-flex bg-info">...</span>
specific
styling.
d-*- inline
inline display
with a <div class="d-inline bg-secondary">...</div>
specific
styling.
d-*- display
<div class="d-inline-block bg-
inline- inline- secondary">...</
block <div class="d-lg-inline-block
block. bg-info">...</di
Page © Copyright by
Bootstrap Cheat
<div
class="d
-
none">..
.</div>
<div
class="d
-lg-
none">..
.</div>
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
bg- It is used to
primary add a blue <div class="bg-primary text-white">text
background.
bg- It is used to
secondary add a grey <div class="bg-secondary"> background
is
background.
bg- It is used to
success add a green <div class="bg-success"> background is
g
background.
bg-info It is used to
add a light <div class="bg-info"> background is
blue ligh
background.
bg- It is used to
warning add a yellow <div class="bg-warning"> background is
y
background.
bg- It is used to
danger add a red <div class="bg-danger"> background is
re
background.
bg-light It is used to
add a light
(white or <div class="bg-light"> background is
whi
light grey)
background.
bg-dark It is used to
add a black <div class="bg-dark"> background is
(dark) blac
background.
Page © Copyright by
Bootstrap Cheat
bg-white It is used to
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
w-
Utility
class that
makes an
element's
width a
percentag
e of its
parent's
width.
<div
Bootstrap includes a wide range of shorthand responsive margin, padding, and gap
m to modifyItan element’s appearance.
utility classes
w- provides <div class="mw-100 bg-success">Maximum
a
maximu
mh- It provides maximum height.
*
<div class="mw-75 bg-success">Maximum
Page © Copyright by
Bootstrap Cheat
m-1 spaced
/ m- div tags
*-# with
margin
on all
sides; <div class="m-4 bg-success d-inline-block">div
wit
star
ranges
from 0
space to
6 spaces.
mt-
1/ the
mt- margin <div class="mt-3 bg-warning d-inline-
block">Spaced
on top.
*-#
mr-
1/ the
mr- margin <div class="mr-3 bg-warning d-inline-
block">Spaced
on right.
*-#
mb-
1/ bottom <div class="mb-3 bg-warning d-inline-
mb- margin. block">Spaced
*-#
ml-
1/ left <div class="mx-3 bg-primary d-inline-
ml- margin. block">Spaced
*-#
*-# margin.
Page © Copyright by
Bootstrap Cheat
Page © Copyright by
Bootstrap Cheat
flex-*- display
row content
horizontally
one after
<div class="d-flex flex-row">
the other
(side- by- <div class="d-flex
flex-md-row">...</div>
side).
Responsive
variations
are
sm,md,lg,xl.
flex-*- reverse the
<div class="d-flex flex-row-reverse">
row- order of
reverse display of <div class="d-flex flex-lg-row-
reverse">.
rows.
flex-*- default
nowrap setting to
display text <div class="d-flex flex-nowrap">..</div>
Page © Copyright by
Bootstrap Cheat
in the flex
Page © Copyright by
Bootstrap Cheat
Conclusion:
In this bootstrap cheat sheet, you can find all the information you need while
learning HTML and front-end development. Furthermore, it can be used as a
reference when building a project using the popular HTML framework.
Refer Interview Preparation Guides
Page © Copyright by
Links to More Interview Ques
Css Interview Questions Laravel Interview Questions Asp Net Interview Questions
Page © Copyright by
Page © Copyright by