Display classes
d-none, d-block, d-inline, d-inline-block, d-flex, d-grid
Show or hide by screen size
d-none d-md-block— hidden on phones, visible from md upd-md-none— visible on phones only
Flexbox classes
Start with d-flex on the parent, then:
| Class | Effect |
|---|---|
flex-column / flex-row |
direction |
justify-content-between / -center / -end |
main-axis alignment |
align-items-center / -start / -end |
cross-axis alignment |
flex-wrap |
allow wrapping |
flex-grow-1 |
child takes free space |
gap-2 |
space between children |
ms-auto |
push an item to the right |
Centre anything: d-flex justify-content-center align-items-center.
Example
Example — Flex utilities and responsive display
HTML
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<div class="container my-3">
<div class="d-flex justify-content-between align-items-center bg-dark text-white p-3 rounded">
<strong>Logo</strong>
<div class="d-flex gap-2">
<a class="btn btn-sm btn-light" href="#">Login</a>
<a class="btn btn-sm btn-warning" href="#">Sign up</a>
</div>
</div>
<div class="d-flex justify-content-center align-items-center bg-info-subtle mt-3 rounded" style="height: 120px;">Perfectly centred</div>
<p class="d-none d-md-block alert alert-success mt-3">Visible on md screens and larger</p>
<p class="d-md-none alert alert-warning mt-3">Visible on small screens only</p>
</div>