The ratio helper keeps a box at a fixed aspect ratio whatever its width, which is perfect for media placeholders, thumbnails, galleries and banners. Pick ratio-1x1, ratio-4x3, ratio-16x9 or ratio-21x9, or set any ratio with the --bs-aspect-ratio variable.
1The four built-in ratios
ratio-1x1, ratio-4x3, ratio-16x9 and ratio-21x9 next to each other, filled with a plain div.
<div class="row g-3">
<div class="col-6 col-md-3">
<div class="ratio ratio-1x1">
<div class="d-flex align-items-center justify-content-center bg-primary-subtle text-primary-emphasis border border-primary-subtle rounded fw-semibold">
1:1
</div>
</div>
</div>
<div class="col-6 col-md-3">
<div class="ratio ratio-4x3">
<div class="d-flex align-items-center justify-content-center bg-primary-subtle text-primary-emphasis border border-primary-subtle rounded fw-semibold">
4:3
</div>
</div>
</div>
<div class="col-6 col-md-3">
<div class="ratio ratio-16x9">
<div class="d-flex align-items-center justify-content-center bg-primary-subtle text-primary-emphasis border border-primary-subtle rounded fw-semibold">
16:9
</div>
</div>
</div>
<div class="col-6 col-md-3">
<div class="ratio ratio-21x9">
<div class="d-flex align-items-center justify-content-center bg-primary-subtle text-primary-emphasis border border-primary-subtle rounded fw-semibold">
21:9
</div>
</div>
</div>
</div>2Video placeholder
A 16:9 poster image with a centred play button, ready for a video player of your choice.
<div class="ratio ratio-16x9 rounded overflow-hidden" style="max-width:36rem">
<div>
<img src="https://images.unsplash.com/photo-1551632436-cbf8dd35adfa?auto=format&fit=crop&w=1600&h=700&q=70" alt="Video poster" class="w-100 h-100 object-fit-cover">
<button type="button" class="btn btn-light rounded-circle position-absolute top-50 start-50 translate-middle shadow" aria-label="Play video"><i class="bi bi-play-fill" aria-hidden="true"></i></button>
</div>
</div>3Square product thumbnails
ratio-1x1 with object-fit-cover gives every product the same tile, whatever the photo size.
Slow-cooked lamb
Espresso martini
Chocolate tart
Chef's tasting plate
Garden salad
Burrata with tomatoes
<div class="row g-2">
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded overflow-hidden border">
<img src="../assets/img/product-9.svg" alt="Slow-cooked lamb" class="object-fit-cover">
</div>
<p class="small text-truncate mt-1 mb-0">Slow-cooked lamb</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded overflow-hidden border">
<img src="../assets/img/product-11.svg" alt="Espresso martini" class="object-fit-cover">
</div>
<p class="small text-truncate mt-1 mb-0">Espresso martini</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded overflow-hidden border">
<img src="../assets/img/product-5.svg" alt="Chocolate tart" class="object-fit-cover">
</div>
<p class="small text-truncate mt-1 mb-0">Chocolate tart</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded overflow-hidden border">
<img src="../assets/img/product-12.svg" alt="Chef's tasting plate" class="object-fit-cover">
</div>
<p class="small text-truncate mt-1 mb-0">Chef's tasting plate</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded overflow-hidden border">
<img src="../assets/img/product-3.svg" alt="Garden salad" class="object-fit-cover">
</div>
<p class="small text-truncate mt-1 mb-0">Garden salad</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded overflow-hidden border">
<img src="../assets/img/product-7.svg" alt="Burrata with tomatoes" class="object-fit-cover">
</div>
<p class="small text-truncate mt-1 mb-0">Burrata with tomatoes</p>
</div>
</div>4Cinematic hero banner
ratio-21x9 for a wide banner with a headline overlay.
Seasonal menus from local farms
Vegan, vegetarian and gluten-free dishes are marked clearly on every menu.
<div class="ratio ratio-21x9 rounded-3 overflow-hidden">
<div>
<img src="https://images.unsplash.com/photo-1494346480775-936a9f0d0877?auto=format&fit=crop&w=1600&h=700&q=70" alt="" class="w-100 h-100 object-fit-cover">
<div class="position-absolute bottom-0 start-0 p-3 p-md-4 text-white" style="background:rgba(0,0,0,.45)">
<h3 class="h4 mb-1">Seasonal menus from local farms</h3>
<p class="small mb-0 d-none d-sm-block">Vegan, vegetarian and gluten-free dishes are marked clearly on every menu.</p>
</div>
</div>
</div>5Map placeholder
A 4:3 box reserved for a map, showing the address until the map loads.
<div class="ratio ratio-4x3" style="max-width:24rem">
<div class="d-flex flex-column align-items-center justify-content-center bg-body-tertiary border rounded text-center p-3">
<span class="fs-1 text-primary"><i class="bi bi-geo-alt-fill" aria-hidden="true"></i></span><strong>Iris Hub</strong><span class="small text-body-secondary">84 Hillcrest Road, Kyoto</span>
</div>
</div>6Custom 3:2 photo
Any ratio works with the --bs-aspect-ratio variable: 2 / 3 = 66.67% for classic photo prints.
<figure class="mb-0" style="max-width:28rem">
<div class="ratio rounded overflow-hidden" style="--bs-aspect-ratio:66.67%">
<img src="https://images.unsplash.com/photo-1559339352-11d035aa65de?auto=format&fit=crop&w=1200&h=800&q=70" alt="Our chef's guide to seasonal autumn produce" class="object-fit-cover">
</div>
<figcaption class="small text-body-secondary mt-1">3:2 · What is new on our winter menu</figcaption>
</figure>7Portrait team cards
A 3:4 portrait ratio (133.33%) for team photos in cards.
Nora Novak
Support Specialist
Owen Haddad
Project Manager
Tariq Fischer
Support Specialist
<div class="row g-3">
<div class="col-6 col-md-4">
<div class="card h-100">
<div class="ratio card-img-top overflow-hidden" style="--bs-aspect-ratio:133.33%">
<img src="https://images.unsplash.com/photo-1494346480775-936a9f0d0877?auto=format&fit=crop&w=1200&h=800&q=70" alt="Nora Novak" class="object-fit-cover">
</div>
<div class="card-body py-2">
<h3 class="h6 mb-0">Nora Novak</h3>
<p class="small text-body-secondary mb-0">Support Specialist</p>
</div>
</div>
</div>
<div class="col-6 col-md-4">
<div class="card h-100">
<div class="ratio card-img-top overflow-hidden" style="--bs-aspect-ratio:133.33%">
<img src="https://images.unsplash.com/photo-1494346480775-936a9f0d0877?auto=format&fit=crop&w=1200&h=800&q=70" alt="Owen Haddad" class="object-fit-cover">
</div>
<div class="card-body py-2">
<h3 class="h6 mb-0">Owen Haddad</h3>
<p class="small text-body-secondary mb-0">Project Manager</p>
</div>
</div>
</div>
<div class="col-6 col-md-4">
<div class="card h-100">
<div class="ratio card-img-top overflow-hidden" style="--bs-aspect-ratio:133.33%">
<img src="https://images.unsplash.com/photo-1565895405140-6b9830a88c19?auto=format&fit=crop&w=1200&h=800&q=70" alt="Tariq Fischer" class="object-fit-cover">
</div>
<div class="card-body py-2">
<h3 class="h6 mb-0">Tariq Fischer</h3>
<p class="small text-body-secondary mb-0">Support Specialist</p>
</div>
</div>
</div>
</div>8Vertical stories
A 9:16 ratio (177.78%) for phone sized stories or short clips in a scrolling row.
<div class="d-flex gap-2 overflow-auto pb-1">
<div class="flex-shrink-0" style="width:7rem">
<div class="ratio rounded-3 overflow-hidden" style="--bs-aspect-ratio:177.78%">
<div>
<img src="https://images.unsplash.com/photo-1579631542761-d7c4e913f8d4?auto=format&fit=crop&w=1200&h=800&q=70" alt="Story by Zoe Quinn" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 start-0 m-1 badge text-bg-dark">Zoe</span>
</div>
</div>
</div>
<div class="flex-shrink-0" style="width:7rem">
<div class="ratio rounded-3 overflow-hidden" style="--bs-aspect-ratio:177.78%">
<div>
<img src="https://images.unsplash.com/photo-1494346480775-936a9f0d0877?auto=format&fit=crop&w=1200&h=800&q=70" alt="Story by Lea Carter" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 start-0 m-1 badge text-bg-dark">Lea</span>
</div>
</div>
</div>
<div class="flex-shrink-0" style="width:7rem">
<div class="ratio rounded-3 overflow-hidden" style="--bs-aspect-ratio:177.78%">
<div>
<img src="https://images.unsplash.com/photo-1682264933304-1943bfa8df38?auto=format&fit=crop&w=1200&h=800&q=70" alt="Story by Elena Alvarez" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 start-0 m-1 badge text-bg-dark">Elena</span>
</div>
</div>
</div>
<div class="flex-shrink-0" style="width:7rem">
<div class="ratio rounded-3 overflow-hidden" style="--bs-aspect-ratio:177.78%">
<div>
<img src="https://images.unsplash.com/photo-1538333581680-29dd4752ddf2?auto=format&fit=crop&w=1200&h=800&q=70" alt="Story by Ivy Moreau" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 start-0 m-1 badge text-bg-dark">Ivy</span>
</div>
</div>
</div>
</div>9Chart area
A 16:9 box that keeps a simple bar chart in proportion on every screen.
<div class="card" style="max-width:36rem">
<div class="card-header small fw-semibold">
Monthly bookings
</div>
<div class="card-body">
<div class="ratio ratio-16x9">
<div class="d-flex align-items-end gap-2" role="img" aria-label="Bar chart of monthly bookings">
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:30%">
</div>
<span class="small text-body-secondary">Jan</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:84%">
</div>
<span class="small text-body-secondary">Feb</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:75%">
</div>
<span class="small text-body-secondary">Mar</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:80%">
</div>
<span class="small text-body-secondary">Apr</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:30%">
</div>
<span class="small text-body-secondary">May</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:23%">
</div>
<span class="small text-body-secondary">Jun</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:62%">
</div>
<span class="small text-body-secondary">Jul</span>
</div>
<div class="flex-fill d-flex flex-column justify-content-end align-items-center h-100">
<div class="w-100 bg-primary rounded-top" style="height:29%">
</div>
<span class="small text-body-secondary">Aug</span>
</div>
</div>
</div>
</div>
</div>10Blog card cover
ratio-16x9 as a card image keeps every post card in a grid the same height.
Five things we learned this year
Jun 5, 2026
<div class="card" style="max-width:22rem">
<div class="ratio ratio-16x9 card-img-top overflow-hidden">
<img src="https://images.unsplash.com/photo-1494346480775-936a9f0d0877?auto=format&fit=crop&w=1200&h=800&q=70" alt="Our favourite tips for busy weeks" class="object-fit-cover">
</div>
<div class="card-body">
<span class="badge text-bg-light border mb-2">tutorial</span>
<h3 class="h6">Five things we learned this year</h3>
<p class="small text-body-secondary mb-0">Jun 5, 2026</p>
</div>
</div>11Caption over a gradient
A 4:3 image with a gradient overlay so white caption text stays readable.
<div class="ratio ratio-4x3 rounded-3 overflow-hidden" style="max-width:24rem">
<div>
<img src="https://images.unsplash.com/photo-1538333581680-29dd4752ddf2?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="w-100 h-100 object-fit-cover">
<div class="position-absolute bottom-0 w-100 p-3 text-white" style="background:linear-gradient(transparent,rgba(0,0,0,.7))">
<strong class="d-block">Dublin</strong><span class="small">Wine pairing</span>
</div>
</div>
</div>12Mixed ratio gallery
Combining 1:1, 4:3 and 16:9 tiles in one responsive grid.
<div class="row g-2">
<div class="col-md-6">
<div class="ratio ratio-4x3 rounded overflow-hidden">
<img src="https://images.unsplash.com/photo-1565895405140-6b9830a88c19?auto=format&fit=crop&w=1200&h=800&q=70" alt="Gallery photo 1" class="object-fit-cover">
</div>
</div>
<div class="col-md-6">
<div class="row g-2">
<div class="col-6">
<div class="ratio ratio-1x1 rounded overflow-hidden">
<img src="https://images.unsplash.com/photo-1541963020-4f9732b3ee29?auto=format&fit=crop&w=800&h=800&q=70" alt="Gallery photo 2" class="object-fit-cover">
</div>
</div>
<div class="col-6">
<div class="ratio ratio-1x1 rounded overflow-hidden">
<img src="https://images.unsplash.com/photo-1570560258879-af7f8e1447ac?auto=format&fit=crop&w=800&h=800&q=70" alt="Gallery photo 3" class="object-fit-cover">
</div>
</div>
<div class="col-12">
<div class="ratio ratio-21x9 rounded overflow-hidden">
<img src="https://images.unsplash.com/photo-1538333581680-29dd4752ddf2?auto=format&fit=crop&w=1600&h=700&q=70" alt="Gallery photo 4" class="object-fit-cover">
</div>
</div>
</div>
</div>
</div>13Thumbnails in table cells
A small ratio-1x1 box keeps order line images square inside a table.
| Image | Item | Price |
|---|---|---|
| Grilled salmon | $24.99 | |
| Truffle pasta | $24.00 | |
| Garden salad | $11.00 |
<table class="table align-middle mb-0">
<thead>
<tr>
<th scope="col"><span class="visually-hidden">Image</span></th>
<th scope="col">Item</th>
<th scope="col" class="text-end">Price</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width:4rem"><div class="ratio ratio-1x1 rounded overflow-hidden"><img src="../assets/img/product-2.svg" alt="Grilled salmon" class="object-fit-cover"></div></td>
<td class="align-middle">Grilled salmon</td>
<td class="align-middle text-end">$24.99</td>
</tr>
<tr>
<td style="width:4rem"><div class="ratio ratio-1x1 rounded overflow-hidden"><img src="../assets/img/product-1.svg" alt="Truffle pasta" class="object-fit-cover"></div></td>
<td class="align-middle">Truffle pasta</td>
<td class="align-middle text-end">$24.00</td>
</tr>
<tr>
<td style="width:4rem"><div class="ratio ratio-1x1 rounded overflow-hidden"><img src="../assets/img/product-3.svg" alt="Garden salad" class="object-fit-cover"></div></td>
<td class="align-middle">Garden salad</td>
<td class="align-middle text-end">$11.00</td>
</tr>
</tbody>
</table>14Empty cover placeholder
A dashed 4:3 area that reserves space for an image that has not been chosen yet.
<div class="ratio ratio-4x3" style="max-width:20rem">
<div class="d-flex flex-column align-items-center justify-content-center border border-2 border-secondary-subtle rounded-3 text-body-secondary wt-border-dashed">
<span class="fs-2"><i class="bi bi-image" aria-hidden="true"></i></span><span class="small">No cover image yet</span>
</div>
</div>15Colour swatches
Empty square ratios make perfect colour swatches for a style guide.
primary
secondary
success
info
warning
danger
<div class="row g-2">
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded-3 bg-primary">
<span class="visually-hidden">primary</span>
</div>
<p class="small text-center mt-1 mb-0">primary</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded-3 bg-secondary">
<span class="visually-hidden">secondary</span>
</div>
<p class="small text-center mt-1 mb-0">secondary</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded-3 bg-success">
<span class="visually-hidden">success</span>
</div>
<p class="small text-center mt-1 mb-0">success</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded-3 bg-info">
<span class="visually-hidden">info</span>
</div>
<p class="small text-center mt-1 mb-0">info</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded-3 bg-warning">
<span class="visually-hidden">warning</span>
</div>
<p class="small text-center mt-1 mb-0">warning</p>
</div>
<div class="col-4 col-md-2">
<div class="ratio ratio-1x1 rounded-3 bg-danger">
<span class="visually-hidden">danger</span>
</div>
<p class="small text-center mt-1 mb-0">danger</p>
</div>
</div>16Video thumbnails with badges
Duration and status badges positioned over 16:9 thumbnails.
Three pasta shapes to make at home
How we make our sourdough every morning
How to choose the right dish
<div class="row g-3">
<div class="col-md-4">
<div class="ratio ratio-16x9 rounded overflow-hidden">
<div>
<img src="https://images.unsplash.com/photo-1625862692743-3f57873bb37c?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 end-0 m-2 badge text-bg-dark">10:31</span><span class="position-absolute top-0 start-0 m-2 badge text-bg-danger">New</span>
</div>
</div>
<p class="small fw-semibold mt-1 mb-0">Three pasta shapes to make at home</p>
</div>
<div class="col-md-4">
<div class="ratio ratio-16x9 rounded overflow-hidden">
<div>
<img src="https://images.unsplash.com/photo-1551632436-cbf8dd35adfa?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 end-0 m-2 badge text-bg-dark">10:34</span>
</div>
</div>
<p class="small fw-semibold mt-1 mb-0">How we make our sourdough every morning</p>
</div>
<div class="col-md-4">
<div class="ratio ratio-16x9 rounded overflow-hidden">
<div>
<img src="https://images.unsplash.com/photo-1579631542761-d7c4e913f8d4?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="w-100 h-100 object-fit-cover"><span class="position-absolute bottom-0 end-0 m-2 badge text-bg-dark">10:59</span>
</div>
</div>
<p class="small fw-semibold mt-1 mb-0">How to choose the right dish</p>
</div>
</div>17Media list
Fixed width 4:3 thumbnails beside article titles in a reading list.
Five wines to pair with a summer dinner
Sep 26, 2025 · 6 min read
Meet the farmers behind our menu
Mar 15, 2026 · 12 min read
A beginner's guide to getting started
Jan 13, 2026 · 4 min read
<ul class="list-unstyled mb-0 vstack gap-3">
<li class="d-flex gap-3"><div class="flex-shrink-0" style="width:6rem"><div class="ratio ratio-4x3 rounded overflow-hidden"><img src="https://images.unsplash.com/photo-1682264933304-1943bfa8df38?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="object-fit-cover"></div></div><div><h3 class="h6 mb-1">Five wines to pair with a summer dinner</h3><p class="small text-body-secondary mb-0">Sep 26, 2025 · 6 min read</p></div></li>
<li class="d-flex gap-3"><div class="flex-shrink-0" style="width:6rem"><div class="ratio ratio-4x3 rounded overflow-hidden"><img src="https://images.unsplash.com/photo-1538333581680-29dd4752ddf2?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="object-fit-cover"></div></div><div><h3 class="h6 mb-1">Meet the farmers behind our menu</h3><p class="small text-body-secondary mb-0">Mar 15, 2026 · 12 min read</p></div></li>
<li class="d-flex gap-3"><div class="flex-shrink-0" style="width:6rem"><div class="ratio ratio-4x3 rounded overflow-hidden"><img src="https://images.unsplash.com/photo-1541963020-4f9732b3ee29?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="object-fit-cover"></div></div><div><h3 class="h6 mb-1">A beginner's guide to getting started</h3><p class="small text-body-secondary mb-0">Jan 13, 2026 · 4 min read</p></div></li>
</ul>18Responsive ratio
A small custom class changes --bs-aspect-ratio per breakpoint: square on phones, 21:9 on tablets and up.
<div class="ratio hp-ratio-resp rounded-3 overflow-hidden">
<img src="https://images.unsplash.com/photo-1570560258879-af7f8e1447ac?auto=format&fit=crop&w=1600&h=700&q=70" alt="Simple dishes, honest ingredients" class="object-fit-cover">
</div>19Round avatars
ratio-1x1 with rounded-circle keeps profile pictures perfectly round even when the source is not square.
<div class="d-flex flex-wrap gap-3">
<div class="text-center" style="width:5rem">
<div class="ratio ratio-1x1 rounded-circle overflow-hidden border border-2 border-primary">
<img src="../assets/img/avatar-1.svg" alt="Felix Morgan" class="object-fit-cover">
</div>
<span class="small d-block text-truncate mt-1">Felix</span>
</div>
<div class="text-center" style="width:5rem">
<div class="ratio ratio-1x1 rounded-circle overflow-hidden border border-2 border-primary">
<img src="../assets/img/avatar-10.svg" alt="Mason Hughes" class="object-fit-cover">
</div>
<span class="small d-block text-truncate mt-1">Mason</span>
</div>
<div class="text-center" style="width:5rem">
<div class="ratio ratio-1x1 rounded-circle overflow-hidden border border-2 border-primary">
<img src="../assets/img/avatar-11.svg" alt="Ethan Kim" class="object-fit-cover">
</div>
<span class="small d-block text-truncate mt-1">Ethan</span>
</div>
<div class="text-center" style="width:5rem">
<div class="ratio ratio-1x1 rounded-circle overflow-hidden border border-2 border-primary">
<img src="../assets/img/avatar-2.svg" alt="Priya Harlow" class="object-fit-cover">
</div>
<span class="small d-block text-truncate mt-1">Priya</span>
</div>
</div>20Loading skeleton
A 16:9 placeholder block with placeholder-glow while the real image and text load.
The skeleton reserves the exact space, so the page does not jump when content arrives.
<div class="card" style="max-width:22rem" aria-hidden="true">
<div class="ratio ratio-16x9 placeholder-glow">
<span class="placeholder"></span>
</div>
<div class="card-body placeholder-glow">
<span class="placeholder col-7 mb-2"></span><span class="placeholder col-4"></span>
</div>
</div>
<p class="small text-body-secondary mt-2 mb-0">The skeleton reserves the exact space, so the page does not jump when content arrives.</p>