Object Fit
Object fit utilities decide how an image or video fills its box: object-fit-contain shows all of it, object-fit-cover fills the box and crops, object-fit-fill stretches, object-fit-scale only shrinks and object-fit-none keeps the natural size. Responsive variants like object-fit-md-cover switch per breakpoint.
1All object-fit values
contain, cover, fill, scale and none on the same wide image in square frames.
object-fit-containobject-fit-coverobject-fit-fillobject-fit-scaleobject-fit-none<div class="row g-3 text-center small">
<div class="col-6 col-md">
<img src="https://images.unsplash.com/photo-1752650736252-dff5244c8a7a?auto=format&fit=crop&w=1600&h=700&q=70" alt="contain" width="120" height="120" class="bg-body-tertiary border rounded-3 d-block object-fit-contain mx-auto"><code>object-fit-contain</code>
</div>
<div class="col-6 col-md">
<img src="https://images.unsplash.com/photo-1752650736252-dff5244c8a7a?auto=format&fit=crop&w=1600&h=700&q=70" alt="cover" width="120" height="120" class="bg-body-tertiary border rounded-3 d-block object-fit-cover mx-auto"><code>object-fit-cover</code>
</div>
<div class="col-6 col-md">
<img src="https://images.unsplash.com/photo-1752650736252-dff5244c8a7a?auto=format&fit=crop&w=1600&h=700&q=70" alt="fill" width="120" height="120" class="bg-body-tertiary border rounded-3 d-block object-fit-fill mx-auto"><code>object-fit-fill</code>
</div>
<div class="col-6 col-md">
<img src="https://images.unsplash.com/photo-1752650736252-dff5244c8a7a?auto=format&fit=crop&w=1600&h=700&q=70" alt="scale" width="120" height="120" class="bg-body-tertiary border rounded-3 d-block object-fit-scale mx-auto"><code>object-fit-scale</code>
</div>
<div class="col-6 col-md">
<img src="https://images.unsplash.com/photo-1752650736252-dff5244c8a7a?auto=format&fit=crop&w=1600&h=700&q=70" alt="none" width="120" height="120" class="bg-body-tertiary border rounded-3 d-block object-fit-none mx-auto"><code>object-fit-none</code>
</div>
</div>2Uniform product grid
object-fit-cover makes images of any shape fill equal square tiles.
<div class="row g-2">
<div class="col-4">
<img src="https://images.unsplash.com/photo-1787647559705-d2ad3322020e?auto=format&fit=crop&w=1600&h=700&q=70" alt="Why motion matters for modern brands" class="w-100 rounded-3 object-fit-cover" style="height:110px">
</div>
<div class="col-4">
<img src="https://images.unsplash.com/photo-1752650736677-94fe8cdb9d5c?auto=format&fit=crop&w=1200&h=800&q=70" alt="Inside our design process" class="w-100 rounded-3 object-fit-cover" style="height:110px">
</div>
<div class="col-4">
<img src="https://images.unsplash.com/photo-1753162658407-93888aaabfae?auto=format&fit=crop&w=800&h=800&q=70" alt="How we ran a rebrand in eight weeks" class="w-100 rounded-3 object-fit-cover" style="height:110px">
</div>
</div>3Logos with contain
object-fit-contain shows the whole logo inside a fixed box without cropping.
<div class="d-flex flex-wrap gap-2">
<img src="../assets/img/logo-5.svg" alt="Partner logo" width="130" height="70" class="object-fit-contain border rounded-3 p-2 bg-body"> <img src="../assets/img/logo-6.svg" alt="Partner logo" width="130" height="70" class="object-fit-contain border rounded-3 p-2 bg-body"> <img src="../assets/img/logo-7.svg" alt="Partner logo" width="130" height="70" class="object-fit-contain border rounded-3 p-2 bg-body">
</div>4Round avatar from a wide photo
object-fit-cover with rounded-circle crops a non-square image into a circle.
<div class="d-flex align-items-center gap-3">
<img src="https://images.unsplash.com/photo-1787647561978-df268f9e9ec2?auto=format&fit=crop&w=1200&h=800&q=70" alt="Kai Kim" width="72" height="72" class="rounded-circle object-fit-cover border">
<div>
<div class="fw-semibold">
Kai Kim
</div>
<div class="small text-body-secondary">
Project Manager
</div>
</div>
</div>5Hero banner crop
A fixed height banner with object-fit-cover keeps its height on every screen.
<img src="https://images.unsplash.com/photo-1777923311853-d14b7beb9fec?auto=format&fit=crop&w=1200&h=800&q=70" alt="Make your next launch unforgettable" class="w-100 rounded-4 object-fit-cover" style="height:160px">6Fill stretches the image
object-fit-fill ignores the aspect ratio, which distorts the picture - compare with cover.
<div class="d-flex flex-wrap gap-3 small">
<figure class="mb-0">
<img src="https://images.unsplash.com/photo-1742440710193-3547e0b9d4db?auto=format&fit=crop&w=800&h=800&q=70" alt="Stretched" width="200" height="90" class="object-fit-fill rounded-3 border d-block">
<figcaption class="mt-1">fill</figcaption>
</figure>
<figure class="mb-0">
<img src="https://images.unsplash.com/photo-1742440710193-3547e0b9d4db?auto=format&fit=crop&w=800&h=800&q=70" alt="Cropped" width="200" height="90" class="object-fit-cover rounded-3 border d-block">
<figcaption class="mt-1">cover</figcaption>
</figure>
</div>7Responsive object fit
object-fit-contain object-fit-md-cover shows the full image on phones and crops it from md.
<img src="https://images.unsplash.com/photo-1742440710226-450e3b85c100?auto=format&fit=crop&w=1600&h=700&q=70" alt="Design that earns attention" class="w-100 rounded-4 border bg-body-tertiary object-fit-contain object-fit-md-cover" style="height:180px">8Gallery with mixed shapes
A two row mosaic: each cell is a fixed height and the images cover it.
<div class="row g-2">
<div class="col-8">
<img src="https://images.unsplash.com/photo-1753162658547-f017a4d84541?auto=format&fit=crop&w=1200&h=800&q=70" alt="Gallery large" class="w-100 rounded-3 object-fit-cover" style="height:200px">
</div>
<div class="col-4 d-flex flex-column gap-2">
<img src="https://images.unsplash.com/photo-1753162658449-e0f19e1a4cfc?auto=format&fit=crop&w=800&h=800&q=70" alt="Gallery small 1" class="w-100 rounded-3 object-fit-cover" style="height:96px"> <img src="https://images.unsplash.com/photo-1742440710453-d5db3a357362?auto=format&fit=crop&w=1600&h=700&q=70" alt="Gallery small 2" class="w-100 rounded-3 object-fit-cover" style="height:96px">
</div>
</div>9Thumbnail list
Small square thumbnails with object-fit-cover in a list of articles.
We design brands people remember
Digital products with personality
Bold ideas, beautifully executed
<ul class="list-unstyled mb-0 d-grid gap-2">
<li class="d-flex gap-2 align-items-center"><img src="https://images.unsplash.com/photo-1753162658547-f017a4d84541?auto=format&fit=crop&w=1600&h=700&q=70" alt="" width="52" height="52" class="rounded-2 object-fit-cover flex-shrink-0"><span class="small">We design brands people remember</span></li>
<li class="d-flex gap-2 align-items-center"><img src="https://images.unsplash.com/photo-1777923311853-d14b7beb9fec?auto=format&fit=crop&w=1200&h=800&q=70" alt="" width="52" height="52" class="rounded-2 object-fit-cover flex-shrink-0"><span class="small">Digital products with personality</span></li>
<li class="d-flex gap-2 align-items-center"><img src="https://images.unsplash.com/photo-1752650736252-dff5244c8a7a?auto=format&fit=crop&w=1600&h=700&q=70" alt="" width="52" height="52" class="rounded-2 object-fit-cover flex-shrink-0"><span class="small">Bold ideas, beautifully executed</span></li>
</ul>10Product image with scale
object-fit-scale never enlarges a small image, it only shrinks large ones.
<div class="border rounded-4 p-2 bg-body" style="max-width:16rem">
<img src="../assets/img/product-4.svg" alt="Launch campaign" class="w-100 object-fit-scale bg-body-tertiary rounded-3" style="height:180px">
<div class="p-2">
<div class="fw-medium">
Launch campaign
</div>
<div class="small">
$57.97
</div>
</div>
</div>11Cover inside a ratio box
ratio ratio-16x9 sets the frame; object-fit-cover fills it with the image.
<div class="ratio ratio-16x9 rounded-4 overflow-hidden" style="max-width:26rem">
<img src="https://images.unsplash.com/photo-1753162658407-93888aaabfae?auto=format&fit=crop&w=800&h=800&q=70" alt="A checklist for your next website launch" class="object-fit-cover">
</div>12Square ratio cards
ratio-1x1 with object-fit-cover gives every card a square cover.
<div class="row g-2">
<div class="col-4">
<div class="ratio ratio-1x1">
<img src="https://images.unsplash.com/photo-1753162657329-beced5a7f63f?auto=format&fit=crop&w=1600&h=700&q=70" alt="Cover 1" class="object-fit-cover rounded-3">
</div>
</div>
<div class="col-4">
<div class="ratio ratio-1x1">
<img src="https://images.unsplash.com/photo-1753162658407-93888aaabfae?auto=format&fit=crop&w=1200&h=800&q=70" alt="Cover 2" class="object-fit-cover rounded-3">
</div>
</div>
<div class="col-4">
<div class="ratio ratio-1x1">
<img src="https://images.unsplash.com/photo-1742440710226-450e3b85c100?auto=format&fit=crop&w=1600&h=700&q=70" alt="Cover 3" class="object-fit-cover rounded-3">
</div>
</div>
</div>13Portrait crop
A tall fixed width and height frame with object-fit-cover turns a landscape photo into a portrait.
<div class="d-flex gap-3 align-items-end">
<img src="https://images.unsplash.com/photo-1787647559705-d2ad3322020e?auto=format&fit=crop&w=1600&h=700&q=70" alt="Kenji Sato" width="110" height="150" class="rounded-3 object-fit-cover">
<div>
<div class="fw-semibold">
Kenji Sato
</div>
<div class="small text-body-secondary">
Finance Lead
</div>
</div>
</div>14Background-like image
An absolutely positioned image with object-fit-cover behaves like a cover background.
Stories told in pixels and motion
Websites we build are fast, accessible and easy for your team to update.
<div class="position-relative rounded-4 overflow-hidden text-white p-4" style="min-height:170px">
<img src="https://images.unsplash.com/photo-1752650736677-94fe8cdb9d5c?auto=format&fit=crop&w=1200&h=800&q=70" alt="" class="position-absolute top-0 start-0 w-100 h-100 object-fit-cover">
<div class="position-absolute top-0 start-0 w-100 h-100 bg-dark bg-opacity-50">
</div>
<div class="position-relative">
<h3 class="h5 fw-bold">Stories told in pixels and motion</h3>
<p class="small mb-0">Websites we build are fast, accessible and easy for your team to update.</p>
</div>
</div>15None keeps original pixels
object-fit-none shows the image at its natural size, cropped to the frame centre.
<img src="https://images.unsplash.com/photo-1742440710453-d5db3a357362?auto=format&fit=crop&w=1600&h=700&q=70" alt="How to choose the right project" class="w-100 object-fit-none rounded-4 border" style="height:140px">16Team grid
Team photos in equal circles, whatever the source image size.
<div class="d-flex flex-wrap gap-3 text-center small">
<div>
<img src="https://images.unsplash.com/photo-1742440710226-450e3b85c100?auto=format&fit=crop&w=1200&h=800&q=70" alt="Arjun" width="80" height="80" class="rounded-circle object-fit-cover d-block mb-1">Arjun
</div>
<div>
<img src="https://images.unsplash.com/photo-1787647561978-df268f9e9ec2?auto=format&fit=crop&w=800&h=800&q=70" alt="Mateo" width="80" height="80" class="rounded-circle object-fit-cover d-block mb-1">Mateo
</div>
<div>
<img src="https://images.unsplash.com/photo-1742440710193-3547e0b9d4db?auto=format&fit=crop&w=1600&h=700&q=70" alt="Hana" width="80" height="80" class="rounded-circle object-fit-cover d-block mb-1">Hana
</div>
</div>17Card top image
A card with a fixed height cover image keeps all cards in a row aligned.
<div class="row g-3">
<div class="col-6">
<div class="border rounded-4 overflow-hidden">
<img src="https://images.unsplash.com/photo-1742440710453-d5db3a357362?auto=format&fit=crop&w=800&h=800&q=70" alt="Designing packaging that survives the shelf" class="w-100 object-fit-cover" style="height:110px">
<div class="p-2 small fw-medium">
Designing packaging that survives the shelf
</div>
</div>
</div>
<div class="col-6">
<div class="border rounded-4 overflow-hidden">
<img src="https://images.unsplash.com/photo-1787647561978-df268f9e9ec2?auto=format&fit=crop&w=1600&h=700&q=70" alt="What our clients asked us most" class="w-100 object-fit-cover" style="height:110px">
<div class="p-2 small fw-medium">
What our clients asked us most
</div>
</div>
</div>
</div>18Contain on a dark stage
object-fit-contain on bg-dark: a lightbox style viewer that never crops.
<div class="bg-dark rounded-4 p-2">
<img src="https://images.unsplash.com/photo-1742440710453-d5db3a357362?auto=format&fit=crop&w=1200&h=800&q=70" alt="The small habits that make a big difference" class="w-100 object-fit-contain" style="height:200px">
</div>19Video poster tile
A cover image in a 21x9 ratio with a play icon.
<div class="ratio ratio-21x9 rounded-4 overflow-hidden" style="max-width:28rem">
<img src="https://images.unsplash.com/photo-1753162658547-f017a4d84541?auto=format&fit=crop&w=1200&h=800&q=70" alt="Video poster" class="object-fit-cover">
<div class="d-flex align-items-center justify-content-center">
<span class="bg-body rounded-circle shadow d-inline-flex align-items-center justify-content-center fs-4 text-primary" style="width:56px;height:56px"><i class="bi bi-play-fill" aria-hidden="true"></i></span>
</div>
</div>20Compare before and after
Two cover images side by side with labels.
<div class="row g-2 small">
<div class="col-6 position-relative">
<img src="https://images.unsplash.com/photo-1753162657329-beced5a7f63f?auto=format&fit=crop&w=1200&h=800&q=70" alt="Before" class="w-100 rounded-3 object-fit-cover" style="height:130px"><span class="position-absolute top-0 start-0 m-2 badge text-bg-dark">Before</span>
</div>
<div class="col-6 position-relative">
<img src="https://images.unsplash.com/photo-1753162658449-e0f19e1a4cfc?auto=format&fit=crop&w=1200&h=800&q=70" alt="After" class="w-100 rounded-3 object-fit-cover" style="height:130px"><span class="position-absolute top-0 start-0 m-2 badge text-bg-primary">After</span>
</div>
</div>