Presented by Swapnil Meshram within mentorship within @devsyncin
π Introduction
π Bootstrap is a powerful, open-source CSS framework developed by Twitter to create responsive, mobile-first websites quickly. When paired with HTML, it simplifies the design process by offering pre-designed components and utility classes.
π What is Bootstrap?
π§ Bootstrap is a front-end framework that includes:
π¦ Predefined CSS classes
π Responsive grid system
π¨ UI components (buttons, cards, modals, etc.)
π² Mobile-first design philosophy
π‘ Bootstrap works best with basic knowledge of HTML and CSS.
πΈ Method 1: CDN (Recommended for Beginners)
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
πΈ Method 2: Download and Host Locally
π§° Download Bootstrap files from:
Then link them in the project directory.
π Basic HTML Structure with Bootstrap
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap Page</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1 class="text-center text-primary">Welcome to Bootstrap</h1>
</div>
</body>
</html>
π¦ Bootstrap Grid System
π 12-column grid for responsive layout
π‘ Use classes like container, row, and col.
π» Example:
<div class="container">
<div class="row">
<div class="col-md-4">Column 1</div>
<div class="col-md-4">Column 2</div>
<div class="col-md-4">Column 3</div>
</div>
</div>
π§ͺ Try resizing the window to see the responsive behaviour.
π§© Common Bootstrap Components
π Buttons
<button class="btn btn-primary">Click Me</button>
<button class="btn btn-danger">Delete</button>
π¦ Cards
<div class="card" style="width: 18rem;">
<img src="..." class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Title</h5>
<p class="card-text">Some text here.</p>
<a href="#" class="btn btn-primary">Go</a>
</div>
</div>
π Forms
<form>
<input type="text" class="form-control" placeholder="Enter Name">
<button class="btn btn-success mt-2">Submit</button>
</form>
π§° Advanced Components
π¦ Navbar
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Site</a>
</nav>
π² Modal
<!-- Trigger -->
<button data-bs-toggle="modal" data-bs-target="#myModal">Launch Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal Title</h5>
</div>
<div class="modal-body">This is a modal!</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
π§ Bootstrap Icons
π» Add this in
to use icons:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
Then use:
<i class="bi bi-house-door"></i>
π§ͺ Advanced Layout Techniques
πΈ Responsive Embeds
<div class="ratio ratio-16x9">
<iframe src="..." title="YouTube video"></iframe>
</div>
πΈ Sticky Header
<nav class="navbar sticky-top navbar-light bg-light">Sticky!</nav>
βοΈ Utilities & Helper Classes
π§ Bootstrap provides utility classes for:
β Spacing β m-3, p-2
β Colors β text-danger, bg-warning
β Text alignment β text-center, text-end
β Display β d-none, d-block
π§ͺ Try combining multiple classes to customise layout easily.
π’ Responsive Design with Breakpoints
π― Bootstrap breakpoints:
sm β small devices
md β medium devices
lg β large
xl β extra large
π Bootstrap Layout Classes
container vs container-fluid
Flex layout β d-flex, justify-content-center
Grid nesting β use .row inside columns
Top comments (0)