HTML/CSSIntermediate#css#media

What is the CSS 'object-fit' property used for?

object-fit controls how a replaced element like <img> or <video> is resized to fit its container box — cover crops to fill while maintaining aspect ratio, contain fits entirely within bounds, and fill stretches to fill (default, may distort).

Example
.avatar {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 50%;
}

Related Questions

1
HTML/CSSBeginner#html#entities

What is the difference between HTML entities and Unicode characters?

Open
2
HTML/CSSBeginner#html#attributes

What is the difference between the id and class attributes?

Open
3
HTML/CSSAdvanced#html#javascript

What is the <template> element used for?

Open