Knowledge Map
image object-fit 본문
MDN에서 그냥 긁어옴
The object-fit
CSS property specifies how a replaced element, such as an <img>
or <video>
, should be resized to fit its container.
/* Keyword values */
object-fit: fill;
object-fit: contain;
object-fit: cover;
object-fit: none;
object-fit: scale-down;
/* Global values */
object-fit: inherit;
object-fit: initial;
object-fit: unset;
Depending on the value you specify for object-fit
, the element may be clipped, scaled, or stretched to fit its box.
Initial value | fill |
---|---|
Applies to | replaced elements |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
The object-fit
property is specified as a single keyword chosen from the list of values below.
Values
fill
- 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.
contain
- 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.
cover
- 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.
none
- The replaced content is not resized.
scale-down
- The content is sized as if
none
orcontain
were specified, whichever would result in a smaller concrete object size.
Comments