THE GITHTML FIELD GUIDE

Stop object-fit from cropping important screenshot labels

If a screenshot loses its edges, inspect object-fit and the dimensions of its image box. Cover fills the box by cropping when aspect ratios differ. Use an uncropped presentation for evidence that depends on labels or context, and reserve intentional cropping for a clearly described detail rather than silently changing what readers can see.

Identify the specific failure

A thumbnail-style component may be reused for a technical screenshot. Its fixed ratio and cover rule can remove the axis labels, status bar, or error message that makes the image useful. The underlying file may be completely intact.

Make a narrow correction

Compare the image's natural aspect ratio with its styled box. Use height: auto for normal responsive screenshots, or contain when a fixed box is necessary. Explain any blank space as a layout choice rather than stretching the image to remove it.

  1. Compare the original image with the rendered box before editing the asset.
  2. Remove cover cropping from evidence whose edges carry meaning.
  3. Retain a full-context image when also presenting an enlarged detail.
css
.report-screenshot { max-width: 100%; height: auto; object-fit: contain; }

Compare the image box with the evidence inside it

Take a 1200 by 800 screenshot placed inside a square card. With object-fit: cover, the image can preserve its proportions while losing content at the edges to fill the square. That makes the result look professionally cropped, but the missing edge might contain the environment name or error severity. Inspect the original image separately and mark which regions establish context. The correction should preserve those regions rather than simply move the crop until the most attractive part of the interface is centered.

Object-position changes where the image content sits within its box; it does not make all cropped material visible. Moving the focus toward one edge may reveal the title while hiding the legend at the other. If both are necessary, use a ratio-preserving unconstrained height or contain within the fixed box. Letterboxing is not inherently a failure. It can be the honest result of preserving the entire screenshot in a differently shaped container, and is preferable to silently discarding evidence.

A full screenshot may still be too detailed to read at phone width. Provide a clearly labeled enlarged detail in addition to the full-context view, and explain exactly what the detail demonstrates. Keep its crop boundaries deliberate and avoid presenting the detail as though it were the complete interface. Review the smallest meaningful text at the actual displayed size, not only by opening the original at full resolution. If neither a full view nor a detail can communicate the result clearly, transcribe the relevant status or message into ordinary document text alongside the image.

Verify the repaired artifact

Inspect all four edges and the smallest relevant label after the correction. An uncropped but unreadably tiny image still needs a better presentation.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All html troubleshooting guides →

Read as MarkdownAll guides

Stop object-fit from cropping important screenshot labels · gitHtml