The object-fit CSS property sets how the content of a replaced element, such as an
CSS Object-fit property from Mozilla MDN.imgorvideo, should be resized to fit its container.
Create a container element with a predetermined size or aspect ratio, put the image inside the container, then use object-fit to adjust the image to the container.
.object-fit-fill
.object-fit-contain
.object-fit-cover
.object-fit-scale-down
.object-fit-fill
☝️ Requires preserveAspectRatio="none"
.object-fit-contain
.object-fit-cover
.object-fit-scale-down
☝️ Chrome will force intrinsic img element height (150px) regardless of svg height
.object-fit-fill
☝️ Requires preserveAspectRatio="none"
.object-fit-contain
.object-fit-cover
.object-fit-scale-down
svg[preserveAspectRatio="<value>"]
none
xMidYMid meet
xMidYMid slice
?
svg[preserveAspectRatio="<value>"]
none
xMidYMid meet
xMidYMid slice
?
.object-fit-fill
.object-fit-contain
.object-fit-cover
.object-fit-scale-down
.object-fit-fill
.object-fit-contain
.object-fit-cover
.object-fit-scale-down
.object-fit-fill
.object-fit-contain
.object-fit-cover
.object-fit-scale-down