Object Fit and Placement

suggest change

object-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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents