Skip to content

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.

containobject-fit-contain
coverobject-fit-cover
fillobject-fit-fill
scaleobject-fit-scale
noneobject-fit-none

2Uniform product grid

object-fit-cover makes images of any shape fill equal square tiles.

Inside our new heart screening clinic
Sleep tips our doctors actually use
How often should you have a health check-up?

3Logos with contain

object-fit-contain shows the whole logo inside a fixed box without cropping.

Partner logo Partner logo Partner logo

4Round avatar from a wide photo

object-fit-cover with rounded-circle crops a non-square image into a circle.

Chloe Patel
Chloe Patel
Backend Engineer

5Hero banner crop

A fixed height banner with object-fit-cover keeps its height on every screen.

See a specialist this week

6Fill stretches the image

object-fit-fill ignores the aspect ratio, which distorts the picture - compare with cover.

Stretched
fill
Cropped
cover

7Responsive object fit

object-fit-contain object-fit-md-cover shows the full image on phones and crops it from md.

Get answers, get better

8Gallery with mixed shapes

A two row mosaic: each cell is a fixed height and the images cover it.

Gallery large
Gallery small 1 Gallery small 2

9Thumbnail list

Small square thumbnails with object-fit-cover in a list of articles.

  • Healthcare that fits your life
  • Your health, our priority
  • Expert doctors, gentle care

10Product image with scale

object-fit-scale never enlarges a small image, it only shrinks large ones.

Blood test
Blood test
$45.42

11Cover inside a ratio box

ratio ratio-16x9 sets the frame; object-fit-cover fills it with the image.

A parent's guide to childhood vaccinations

12Square ratio cards

ratio-1x1 with object-fit-cover gives every card a square cover.

Cover 1
Cover 2
Cover 3

13Portrait crop

A tall fixed width and height frame with object-fit-cover turns a landscape photo into a portrait.

Freya Nguyen
Freya Nguyen
Operations Manager

14Background-like image

An absolutely positioned image with object-fit-cover behaves like a cover background.

Book a doctor in minutes

Clear prices, honest advice and no surprises along the way.

15None keeps original pixels

object-fit-none shows the image at its natural size, cropped to the frame centre.

Five things we learned this year

16Team grid

Team photos in equal circles, whatever the source image size.

AmaraAmara
FelixFelix
RubyRuby

17Card top image

A card with a fixed height cover image keeps all cards in a row aligned.

What to expect at your first dental visit
What to expect at your first dental visit
Understanding your blood test results
Understanding your blood test results

18Contain on a dark stage

object-fit-contain on bg-dark: a lightbox style viewer that never crops.

How to choose the right service

19Video poster tile

A cover image in a 21x9 ratio with a play icon.

Video poster

20Compare before and after

Two cover images side by side with labels.

BeforeBefore
AfterAfter