CSS object-fit Playground

Mr. Harun’s photo frames: set object-fit and object-position, the box is measured from the real element, and a ghost of the whole picture shows the parts cut…

Why it matters

Every profile photo, product card and hero needs a picture that fits a fixed box without distortion. object-fit: cover solves it in one line, with no background-image trick and no lost alt.

The key idea

object-fit sets how the content fills the box, not the box’s size

Common mistakes

Try it in this playground