Interview Question

What is object-fit?

object-fit controls how an image or video is resized inside its box.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

The object-fit property controls how replaced content fits its content box. • cover fills the box and may crop the content. • contain preserves the complete content and may leave empty space. • It commonly affects images and videos with set dimensions.

💡 Simple Example

img { width: 20rem; height: 12rem; object-fit: cover; }

⚡ Quick Revision

object-fit controls how an image or video is resized inside its box.