🎯 Learning Objectives
- Master Bootstrap cards, buttons, and alerts
- Learn navbar components
- Use spacing utilities (margin & padding)
- Redesign portfolio with Bootstrap
🎴 Bootstrap Cards
Cards are flexible content containers with multiple variants and options.
Basic Card Structure:
<div class="card">
<img src="image.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Card Title</h5>
<p class="card-text">Card content goes here.</p>
<a href="#" class="btn btn-primary">Button</a>
</div>
</div>
📱 Visual Result:
Featured Course
📐 Spacing Utilities
Bootstrap provides utility classes for controlling spacing (margin and padding):
| Class | Property | Size | Example |
|---|---|---|---|
m-3 |
Margin all sides | 1rem (16px) | <div class="m-3"> |
mt-4 |
Margin top | 1.5rem (24px) | <div class="mt-4"> |
mb-5 |
Margin bottom | 3rem (48px) | <div class="mb-5"> |
p-3 |
Padding all sides | 1rem (16px) | <div class="p-3"> |
px-4 |
Padding left & right | 1.5rem (24px) | <div class="px-4"> |
py-2 |
Padding top & bottom | 0.5rem (8px) | <div class="py-2"> |
📏 Spacing Scale:
0= 01= 0.25rem (4px)2= 0.5rem (8px)3= 1rem (16px)4= 1.5rem (24px)5= 3rem (48px)
Directions: t=top, b=bottom, l=left, r=right, x=horizontal, y=vertical
🎨 Activity: Redesign Portfolio with Bootstrap
Task: Convert Your Portfolio to Bootstrap
Objective: Take your existing portfolio and redesign it using Bootstrap components
Requirements:
- Responsive navbar with brand and navigation links
- Hero section with call-to-action button
- Skills section using Bootstrap cards
- Apply spacing utilities throughout
- Test on mobile, tablet, and desktop
Complete Bootstrap Portfolio Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Bootstrap Portfolio</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="#">My Portfolio</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 ms-auto">
<li class="nav-item">
<a class="nav-link" href="#about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#skills">Skills</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#projects">Projects</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Hero Section -->
<section class="bg-primary text-white text-center py-5">
<div class="container">
<h1 class="display-4">Welcome to My Portfolio</h1>
<p class="lead">I'm a Web Developer</p>
<a href="#projects" class="btn btn-light btn-lg">View My Work</a>
</div>
</section>
<!-- Skills Section -->
<section id="skills" class="py-5">
<div class="container">
<h2 class="text-center mb-4">My Skills</h2>
<div class="row">
<div class="col-md-4 mb-3">
<div class="card text-center">
<div class="card-body">
<h3>HTML5</h3>
<p>Semantic markup and structure</p>
</div>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="card text-center">
<div class="card-body">
<h3>CSS3</h3>
<p>Styling and responsive design</p>
</div>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="card text-center">
<div class="card-body">
<h3>Bootstrap</h3>
<p>Rapid development framework</p>
</div>
</div>
</div>
</div>
</div>
</section>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js">
</script>
</body>
</html>
✅ Today's Deliverable
- Bootstrap navbar implemented with brand and navigation
- At least 3 card components created with images
- Buttons with different Bootstrap styles applied
- Spacing utilities (margin & padding) used throughout
- Portfolio redesigned with Bootstrap components
- Fully responsive on all devices (mobile, tablet, desktop)
🎉 Congratulations!
You've completed Week 5: Bootstrap Framework! You now know how to:
- Set up Bootstrap and use its CDN
- Create responsive layouts with the 12-column grid system
- Build modern UIs with Bootstrap components (cards, navbars, buttons)
- Apply spacing utilities for professional layouts
Next week: You'll dive into JavaScript and add interactivity to your websites!