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…
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.
object-fit sets how the content fills the box, not the box’s size
fill ignores the ratio. Set object-fit: cover to fill with a crop, or contain to fit it whole.object-fit is set but the picture does not change The box needs both a width and a height, in another ratio than the picture. With height: auto the img takes the picture’s ratio, so there is nothing to fit.background-image and it does nothing object-fit only applies to replaced elements like img and video. For a background use background-size: cover or contain (and background-position, whose default is 0% 0%, not the centre).fill The circle on the cloth turns oval: the scales across and down differ. That is why photos so often look squashed.contain The whole photo fits, and empty room appears inside the frame. Good for a logo that must not be cut.cover, then type an object-position yourself Say left top or 30% 0%. The visible part moves; the faint ghost shows which side is dropped.height to auto Change the mode to anything: nothing changes. The box takes the photo’s ratio, so there is nothing to fit.