Front-end · formation gratuite
Bootstrap Tutorial
Create responsive sites quickly with Bootstrap
- Débutant
- 12 chapitres
- Exemples de code
- 100 % gratuit
Introduction to Bootstrap
Bootstrap is the world's most popular CSS framework for quickly creating responsive and mobile-first websites.
🚀 Why use Bootstrap?
- ✅ Time saving - Ready-to-use components
- ✅ Responsive - Mobile-first by default
- ✅ Consistency - Uniform design
- ✅ Community - Complete documentation and active support
- ✅ Customizable - Easy to adapt to your brand
📦 Installation
There are several ways to integrate Bootstrap into your project.
Via CDN (simplest)
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- JavaScript Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
📐 Grid System
The Bootstrap grid system uses Flexbox and allows you to create responsive layouts with 12 columns.
Basic structure
<div class="container">
<div class="row">
<div class="col-md-6">Colonne 1</div>
<div class="col-md-6">Colonne 2</div>
</div>
</div>
Breakpoints
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)
📦 Containers
Containers are the basic elements for containing and aligning your content.
<!-- Container fixe -->
<div class="container">...</div>
<!-- Container fluide (100% largeur) -->
<div class="container-fluid">...</div>
<!-- Container responsive -->
<div class="container-md">...</div>
✍️ Typography
Bootstrap provides default styles for all typographic elements.
<h1 class="display-1">Display 1</h1>
<p class="lead">Texte important</p>
<p class="text-muted">Texte atténué</p>
<mark>Texte surligné</mark>
🎨 Colors
Bootstrap offers contextual color classes for text and backgrounds.
<!-- Couleurs de texte -->
<p class="text-primary">Texte primaire</p>
<p class="text-success">Texte succès</p>
<p class="text-danger">Texte danger</p>
<!-- Arrière-plans -->
<div class="bg-primary text-white">Fond primaire</div>
🔘 Buttons
Bootstrap offers many ready-to-use button styles.
<button class="btn btn-primary">Primaire</button>
<button class="btn btn-success">Succès</button>
<button class="btn btn-outline-primary">Outline</button>
<button class="btn btn-lg">Grand</button>
🧭 Navbar
The Bootstrap navbar is responsive and customizable.
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Logo</a>
<button class="navbar-toggler">...</button>
</div>
</nav>
🃏 Cards
Cards are flexible containers for displaying content.
<div class="card" style="width: 18rem;">
<img src="..." class="card-img-top">
<div class="card-body">
<h5 class="card-title">Titre</h5>
<p class="card-text">Contenu...</p>
<a href="#" class="btn btn-primary">Bouton</a>
</div>
</div>
📝 Forms
Bootstrap automatically styles form elements.
<form>
<div class="mb-3">
<label class="form-label">Email</label>
<input type="email" class="form-control">
</div>
<button class="btn btn-primary">Envoyer</button>
</form>
🪟 Modals
Modals are dialog windows that appear above the content.
<!-- Bouton déclencheur -->
<button data-bs-toggle="modal" data-bs-target="#myModal">Ouvrir</button>
<!-- Modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">...</div>
</div>
</div>
🛠️ Utility Classes
Bootstrap offers utility classes for spacing, display, flexbox, etc.
Spacing (margin and padding)
<!-- m = margin, p = padding -->
<!-- t/b/s/e = top/bottom/start/end -->
<!-- 0-5 = taille (0 à 3rem) -->
<div class="mt-3">Margin top 3</div>
<div class="p-4">Padding 4</div>
<div class="mx-auto">Centré</div>
Display and Flexbox
<div class="d-flex justify-content-between">...</div>
<div class="d-none d-md-block">Visible sur MD+</div>
🎓 Next Steps
Congratulations! You now master the basics of Bootstrap.
✅ What you learned:
- Bootstrap installation and configuration
- Responsive grid system
- Containers and breakpoints
- Typography and colors
- Buttons and components
- Navbar and navigation
- Cards for content
- Styled forms
- Interactive modals
- Utility classes