Object Fit and Placement
suggest changeobject-fit controls how replaced content such as an image or video fits its content box. object-position chooses its alignment within that box:
.thumbnail {
inline-size: 100%;
aspect-ratio: 16 / 9;
object-fit: cover;
object-position: 50% 30%;
}
cover fills the box and may crop content. contain preserves the complete content and may leave unused space. Other values include fill, none, and scale-down.
Set intrinsic width and height attributes on HTML images when known; browsers can reserve the correct aspect-ratio space before the image loads and reduce layout shift.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents