Style objectFit Property
Style objectFit Property
The objectFit property is used to define how we can adjust and resize the img or video element to fit into the container. It tells us how to fill a container i.e, suggesting various ways for it.
Syntax:-
Its syntax is:- object.style.objectFit OR object.style.objectFit = fill | contain | cover | scale-down | none | initial | inherit
Return:-
Its return is:- string having object-fit of an element
Further Explanation:-
Value | Description |
---|---|
fill | The replaced content is sized to fill the element's content-box. |
contain | The replaced content is scaled to maintain its aspect ratio while fitting within element content-box. |
cover | The replaced content is sized to maintain its aspect ratio while filling element entire content-box. |
none | The replaced content is not resized. |
scale-down | The content is sized as if none or contain were specified. |
initial | Sets property to its default value. |
inherit | Inherits property from its parent element. |