James Williams
Birmingham Newman University
jwilliams@staff.newman.ac.uk
3-hour session
Speed: Rapid development with pre-built components
Consistency: Uniform design across browsers
Responsive: Mobile-first responsive design
Customizable: Easy to customize and extend
See Moodle for supporting materials.
Bootstrap 5 Key Features:
✓ CSS Grid System (12 columns)
✓ Responsive Breakpoints
✓ Pre-built Components
✓ Utility Classes
✓ JavaScript Plugins
✓ Sass/SCSS Support
✓ No jQuery Dependency
✓ Improved Accessibility
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Bootstrap Page</title>
<!-- Bootstrap CSS -->
<link
href="../../libs/bootstrap/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<!-- Your content here -->
<!-- Bootstrap JS -->
<script
src="../../libs/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Bootstrap Grid Classes:
.col-* (Extra small: <576px)
.col-sm-* (Small: ≥576px)
.col-md-* (Medium: ≥768px)
.col-lg-* (Large: ≥992px)
.col-xl-* (Extra large: ≥1200px)
.col-xxl-* (Extra extra large: ≥1400px)
* = number of columns (1-12)
<div class="container">
<div class="row">
<div class="col-md-6">Left Column</div>
<div class="col-md-6">Right Column</div>
</div>
</div>
.container: Responsive container with max-width.row: Horizontal group of columns.col-md-6: 6 columns on medium screens and up<div class="container">
<div class="row">
<div class="col-12 col-md-8 col-lg-6">
Main Content
</div>
<div class="col-12 col-md-4 col-lg-6">
Sidebar
</div>
</div>
</div>
Mobile: 12 columns (full width each)
Tablet: 8 + 4 columns
Desktop: 6 + 6 columns
Container Types:
<div class="container">...</div>
<!-- Responsive with max-width -->
<div class="container-fluid">...</div>
<!-- Full width, no max-width -->
<div class="container-sm">...</div>
<!-- Responsive at small breakpoint -->
Common Bootstrap Components:
Navigation & Navbar
Buttons & Button Groups
Cards & Card Groups
Forms & Form Controls
Alerts & Badges
Modals & Dropdowns
Carousel & Pagination
Tables & Lists
Button Classes:
<button class="btn btn-primary">Primary</button>
<button class="btn btn-secondary">Secondary</button>
<button class="btn btn-success">Success</button>
<button class="btn btn-danger">Danger</button>
<button class="btn btn-warning">Warning</button>
<button class="btn btn-info">Info</button>
<button class="btn btn-light">Light</button>
<button class="btn btn-dark">Dark</button>
<div class="card" style="width: 18rem;">
<img src="product.jpg" class="card-img-top" alt="Product">
<div class="card-body">
<h5 class="card-title">Product Name</h5>
<p class="card-text">Product
description...</p>
<a href="#" class="btn btn-primary">Add to
Cart</a>
</div>
</div>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container">
<a class="navbar-brand"
href="#">E-Commerce</a>
<button class="navbar-toggler" type="button"
data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span
class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse"
id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item"><a
class="nav-link" href="#">Home</a></li>
<li class="nav-item"><a
class="nav-link" href="#">Products</a></li>
</ul>
</div>
</div>
</nav>
<form>
<div class="mb-3">
<label for="email" class="form-label">Email
address</label>
<input type="email" class="form-control"
id="email">
</div>
<div class="mb-3">
<label for="password"
class="form-label">Password</label>
<input type="password" class="form-control"
id="password">
</div>
<button type="submit" class="btn
btn-primary">Submit</button>
</form>
Utility Classes:
Spacing: m-*, p-*, mt-*, mb-*, etc.
Colors: text-primary, bg-success, etc.
Typography: text-center, fw-bold, etc.
Flexbox: d-flex, justify-content-center, etc.
Display: d-none, d-block, d-md-flex, etc.
Borders: border, rounded, shadow, etc.
Position: position-relative, top-0, etc.
E-commerce Page Structure:
<!-- Header/Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark
bg-dark">...</nav>
<!-- Main Content -->
<div class="container mt-4">
<div class="row">
<!-- Sidebar -->
<div class="col-md-3">Filters</div>
<!-- Products -->
<div class="col-md-9">Product Grid</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-light mt-5">...</footer>
Time: 45 minutes
This task will help you understand Bootstrap's grid system and responsive design
Take a break, ask questions, or catch up on the previous task.
Next: Secondary slides and Task 2
Custom CSS Example:
:root {
--bs-primary: #ff6b6b;
--bs-secondary: #ee5a24;
}
.btn-custom {
background-color: var(--bs-primary);
border-color: var(--bs-primary);
}
This card demonstrates how Bootstrap components look with different themes.
Free Themes: 30+ professionally designed Bootstrap themes
Easy Integration: Just replace the Bootstrap CSS link
Customizable: Modify colors, fonts, and spacing
Responsive: All themes work on all devices
Click the theme buttons to see how Bootstrap components change with different themes!
JavaScript Components:
Modals & Dialogs
Dropdown Menus
Collapse & Accordion
Carousel & Slideshows
Tooltips & Popovers
Scrollspy & Affix
Toast Notifications
Offcanvas Sidebar
Custom Build Process:
1. Install Bootstrap Sass
2. Import only needed components
3. Compile with custom variables
4. Minify for production
E-commerce Patterns:
Product Cards:
<div class="card h-100">
<img class="card-img-top">
<div class="card-body d-flex flex-column">
<h5 class="card-title"></h5>
<p class="card-text flex-grow-1"></p>
<button class="btn btn-primary mt-auto">Add to
Cart</button>
</div>
</div>
Useful Tools:
- Bootstrap Icons
- Bootstrap Themes
- Bootstrap Studio
- Bootstrap Build Tools
Time: 45 minutes
This task will help you build a complete responsive e-commerce interface
Bootstrap Components & Customization - Advanced styling and component usage