monks/object_fit
The object-fit CSS property sets how the content of a {{ glossary(“replaced elements”, “replaced element”)}}, such as an {{HTMLElement(“img”)}} or {{HTMLElement(“video”)}}, should be resized to fit its container.
The
object-fitproperty has no effect on {{HTMLElement(“iframe”)}}, {{HTMLElement(“embed”)}}, and {{HTMLElement(“fencedframe”)}} elements.
You can alter the alignment of the replaced element’s content object within the element’s box using the {{cssxref(“object-position”)}} property.
Values
pub const contain: #(String, String)
- : The replaced content is scaled to maintain its {{glossary(“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” or “pillarboxed” if its aspect ratio does not match the aspect ratio of the box.
pub const cover: #(String, String)
- : 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.
pub const fill: #(String, String)
- : The replaced content is sized to fill the element’s content box. The entire object will completely fill the box. If the object’s {{glossary(“aspect ratio”)}} does not match the aspect ratio of its box, then the object will be stretched to fit.
pub const revert_layer: #(String, String)
pub const scale_down: #(String, String)
- : The content is sized as if
noneorcontainwere specified, whichever would result in a smaller concrete object size.