object-fit

Jump to: navigation, search

object-fit


W3C Candidate Recommendation

Summary

The object-fit property defines how content of a replaced element (e.g. a video or an image) is made to fit the dimensions of its containing box

Overview table

Initial value fill
Applies to replaced elements
Inherited No
Media visual
Computed value as specified
Animatable No
CSS Object Model Property

Syntax

  • object-fit: cover
  • object-fit: none
  • object-fit: scale-down
  • object-fit: fill
  • object-fit: contain


Values

fill
The replaced content is sized to fill the element's box
contain
The replaced content is sized to to maintain its aspect ratio while fitting within the element's content box
cover
The replaced content is sized to maintain its aspect ratio while filling the element's entire content box
none
The replaced content is not resized to fit inside the element's content box
scale-down
Size the content as if ‘none’ or ‘contain’ were specified, whichever would result in a smaller concrete object size


Needs Examples: This section should include examples.



Related specifications

Specification Status Related Changes
CSS Image Values and Replaced Content Module Level 3 W3C Candidate Recommendation

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic Support 32
Unsupported
Unsupported
≥ 10.6 ≤12.1, 18+ -o
Unsupported

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic Support Unsupported
Unsupported
Unsupported
Unsupported
Unsupported
≥ 11 ≤12.1 -o
Unsupported
Unsupported


Compatibility notes

Browser Version Note
Opera 18+ The feature can be enabled through experimental web features flag from 18+

See also

Related articles

Generated and Replaced Content








  • object-fit


Multimedia





  • object-fit






Video





  • object-fit