object-fit

The object-fit CSS property sets how the content of a replaced element, such as an or

Initial value fill
Applies to replaced elements

Syntax

  
object-fit: cover;
  

Values

The replaced content is scaled to maintain its aspect ratio while fitting within the element’s content box. The entire object is made to fill the box, while preserving its aspect ratio, so the object will be "letterboxed" if its aspect ratio does not match the aspect ratio of the box.
The replaced content is sized to maintain its aspect ratio while filling the element’s entire content box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be clipped to fit.
The replaced content is sized to fill the element’s content box. The entire object will completely fill the box. If the object's aspect ratio does not match the aspect ratio of its box, then the object will be stretched to fit.
The replaced content is not resized.
The content is sized as if none or contain were specified, whichever would result in a smaller concrete object size.

Browser support

object-fitchrome32edge79firefox36ieopera19safari10

We use cookies to improve your experience. Learn more in our Privacy policy.

×