object-fit

noun

say it: “OB-jekt FIT” /ˈɑbdʒɛkt fɪt/

A CSS property that decides how an image fills its box: cover fills the box and trims the edges, contain shows the whole picture with space around it.

What does object-fit do?

object-fit decides how an image fills its box: stretched, cropped to fill (cover), or fitted inside (contain).

.product-photo { width: 200px; height: 200px; object-fit: cover; }

In a sentence

  • “With object-fit: cover, the tall cat photos and the wide dog photos all fill their square frames without stretching.”

Level: Apprentice · More CSS terms at this level

Updated