Bootstrap - Intro
Bootstrap - Intro
DAY 12
Bootstrap
Bootstrap is a free front-end framework for faster and easier web development
It includes HTML and CSS based design templates for typography, forms, buttons, tables,
navigation, modals, image carousels and many other, as well as optional JavaScript
plugins
It also gives you the ability to easily create responsive designs
Versions
The main differences between Bootstrap 5 and Bootstrap 3 & 4, is that Bootstrap 5 has
switched to vanilla JavaScript instead of jQuery.
Advantages of 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 5 is compatible with all modern browsers (Chrome,
Firefox, Edge, Safari, and Opera). Note that if you need support for IE11 and down, you
must use either BS4 or BS3.
Where to Get Bootstrap 5?
There are two ways to start using Bootstrap 5 on your own web site.
When you only need to include Bootstrap’s compiled CSS or JS, you can use jsDelivr.
CSS - Copy-paste the stylesheet <link> into your <head> before all other stylesheets to
load our CSS.
<linkhref="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"integrity="sha384gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6
csBvApHHNl/vI1Bx" crossorigin="anonymous">
Using Bootstrap CDN
JS
Many of our components require the use of JavaScript to function. Specifically, they
require our own JavaScript plugins and Popper. Place one of the following <script>s near
the end of your pages, right before the closing </body> tag, to enable them.
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-
MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/
tWtIaxVXM" crossorigin="anonymous"></script>
Color
Bootstrap is supported by an
extensive color system that
themes our styles and
components. This enables
more comprehensive
customization and extension
for any project.
Text Color
To use contextual classes for the font color, you should include the text class prefix in the
beginning:
<p class="text-success">Success.</p>
Background Color
color the background instead of the characters themselves, you should use the bg class
prefix:
<p class="bg-success">Success.</p>
Buttons
Bootstrap’s custom button styles for actions in forms, dialogs, and more with support for
multiple sizes, states, and more.
<button type="button" class="btn btn-primary">Primary</button>
Outline buttons
Activate/Disable Buttons
<button class="btn disabled" type="button">Disabled</button>
<button class="btn active" type="button">Active</button>
<a href="#" class="btn disabled">Disabled</a>
Containers
Containers are a fundamental building block of Bootstrap that contain, pad, and align
your content within a given device or viewport.
Containers are the most basic layout element in Bootstrap and are required when using
our default grid system.
Containers
<div class="container">
</div>
Responsive containers
Responsive containers allow you to specify a class that is 100% wide until the specified
breakpoint is reached, after which we apply max-widths for each of the higher
breakpoints.
For example, .container-sm is 100% wide to start until the sm breakpoint is reached,
where it will scale up with md, lg, xl, and xxl.
Eg:
Use .container-fluid for a full width container, spanning the entire width of the viewport.
<div class="container-fluid">
...
</div>
Spacing
Bootstrap includes a wide range of shorthand responsive margin, padding, and gap utility
classes to modify an element’s appearance.
s - (start) for classes that set margin-left or padding-left in LTR, margin-right or padding-
right in RTL
e - (end) for classes that set margin-right or padding-right in LTR, margin-left or padding-
left in RTL
blank - for classes that set a margin or padding on all 4 sides of the element
Where size is one of:
1 - (by default) for classes that set the margin or padding to $spacer * .25
2 - (by default) for classes that set the margin or padding to $spacer * .5
3 - (by default) for classes that set the margin or padding to $spacer
4 - (by default) for classes that set the margin or padding to $spacer * 1.5
5 - (by default) for classes that set the margin or padding to $spacer * 3
Use border utilities to quickly style the border and border-radius of an element. Great for
images, buttons, or any other element.
Border color
Border-width (1 to 5)
Text - color
<p class="text-primary">
Text alignment
<p class="fs-1">text</p>
<p class="fs-2">text</p>
<p class="fs-3">text</p>
<p class="fs-5">text</p>
<p class="fs-6">text</p>
background color
<p class="bg-primary">
Background gradient