Layout Lesson 4 of 12
Bootstrap Responsive Breakpoints
Make layouts change with screen size using breakpoints sm, md, lg, xl and xxl, combine column classes, reorder columns, and hide or show content on phones.
The real power of the grid is that columns can have different widths on different screen sizes: stacked on a phone, side by side on a laptop. Bootstrap does this with breakpoints.
Breakpoints
| Name | Infix | Screen width | Typical device |
|---|---|---|---|
| Extra small | (none) | under 576px | Phones |
| Small | sm | ≥ 576px | Large phones |
| Medium | md | ≥ 768px | Tablets |
| Large | lg | ≥ 992px | Laptops |
| Extra large | xl | ≥ 1200px | Desktops |
| XXL | xxl | ≥ 1400px | Big monitors |
A class like col-md-6 means "6 columns wide from medium screens up". Below medium, the column falls back to full width.
Stack on phones, side by side on bigger screens
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<div class="row g-3">
<div class="col-12 col-md-4"><div class="p-3 bg-primary-subtle">🧮 Math</div></div>
<div class="col-12 col-md-4"><div class="p-3 bg-success-subtle">🔬 Science</div></div>
<div class="col-12 col-md-4"><div class="p-3 bg-warning-subtle">📚 English</div></div>
</div>
</div>
Open this on a phone, or press Try it and look at the result panel: in a narrow frame the boxes stack; at 768px or wider they sit in three columns. (col-12 is the default, so class="col-md-4" alone works too.)
Several breakpoints at once
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<div class="row g-2">
<div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 1</div></div>
<div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 2</div></div>
<div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 3</div></div>
<div class="col-12 col-sm-6 col-lg-4 col-xl-3"><div class="p-3 border">Product 4</div></div>
</div>
</div>
One per row on phones, two from sm, three from lg, four from xl. This is the typical layout for product grids.
The shortcut: row-cols
<div class="row row-cols-1 row-cols-sm-2 row-cols-lg-4 g-3">
<div class="col">...</div>
<div class="col">...</div>
</div>
row-cols-* on the row sets how many columns per line, so each child only needs col.
Showing and hiding by screen size
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<p class="d-md-none alert alert-warning">📱 You're on a small screen.</p>
<p class="d-none d-md-block alert alert-success">💻 You're on a medium or larger screen.</p>
</div>
d-nonehides an element on all sizes.d-md-blockshows it (as a block) from medium up.d-md-nonehides it from medium up.
Reordering columns
<link rel="stylesheet" href="/vendor/bootstrap.min.css">
<div class="container py-3">
<div class="row g-2">
<div class="col-md-8 order-md-2"><div class="p-3 bg-light border">Main content</div></div>
<div class="col-md-4 order-md-1"><div class="p-3 bg-info-subtle">Sidebar</div></div>
</div>
</div>
In the HTML, the main content comes first (good for phones and screen readers). From md up, order-md-1 moves the sidebar to the left.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04