A property card looks right in a 16:9 layout. Switch it to a square on mobile and the doorway drifts toward the right edge. The file hasn’t changed, and neither has the CSS focal percentage. What changed is the space available for the image to move.

Start with the box, not the percentage

With object-fit: cover, the browser preserves the image’s aspect ratio and scales it until both dimensions cover the element’s content box. The image can extend beyond that box; what you see is the clipped part.

A two-value percentage object-position aligns that percentage of the rendered image to the same percentage of the box. So object-position: 73% 50% means the point 73% across the image lands 73% across the box, not at its center.

Two crops of a living and dining room; the square crop cuts off more of the left window and right doorway

Calculated crops of the same original 1536 × 1024 portfolio image, using the same 73% horizontal and 50% vertical alignment. These are illustrative renders, not browser screenshots or results from the separate numerical example.

Work one example through

Take a 1600 × 900 image whose focal feature is 73% from the left. These are calculated examples, not measured browser results:

Content box Rendered image Horizontal position Feature from box’s left edge
480 × 270 480 × 270 50% or 73% 350.4 px
300 × 300 533.33 × 300 50% 272.67 px
300 × 300 533.33 × 300 73% 219 px
300 × 300 533.33 × 300 100% 156 px

The calculation for a simple percentage is:

scale = max(boxWidth / sourceWidth, boxHeight / sourceHeight) renderedWidth = sourceWidth × scale left = (boxWidth - renderedWidth) × positionFraction featureX = renderedWidth × featureFraction + left 

In the wide box, there’s no horizontal overflow, so the percentage makes no horizontal difference. In the square, putting the feature exactly at 150 px would require about 102.6%. CSS can accept that value, but here it would uncover a strip at the right edge. If the box must stay covered, 100% is as far as this image can move toward the target using a simple horizontal percentage.

Check the whole feature at each breakpoint

  1. Record the chosen file with the image’s currentSrc and note its intrinsic dimensions. A different source can make a crop look like a CSS bug.
  2. Inspect the content box, without padding or borders. Reproduce the issue at the actual card width, not just at a device’s nominal screen width.
  3. Compare screenshots of the wide and narrow layouts after the image loads. Check both edges of the important feature; a focal point can be visible while part of the feature is missing. Allow a little room for fractional pixel rounding.
  4. If the same image can’t keep its subject intact without exposing a gap, adjust the card ratio, use a framed contain treatment, or supply an alternate crop. The HTML standard’s responsive image guidance calls the last option art direction. Use the picture element when the composition should change, not just when the same composition needs a sharper file.

The next time a card crops badly, check what the layout and selected file actually leave available to move. Sometimes the right fix is a different crop, not a bigger percentage.

For a practical example of switching image sources by viewport, see Mads Stoumann’s DEV guide to responsive image art direction.

Image credit: The cover and crop comparison use the same living and dining virtual-staging sample from the Pixel Perfects Solutions design portfolio. Pixel Perfects Solutions is the company behind EstateAI.