← All Tools

CSS object-fit & object-position Playground

See exactly how each object-fit keyword treats an image whose aspect ratio doesn't match its container — and tune object-position by clicking on a 2D pad. The CSS at the bottom updates live.

Preview

object-fit preview
px

Settings

50% 50%
%
%

Generated CSS


Cheat sheet

fillStretch to fit (default). Aspect ratio is broken. containFit entirely inside the box (letterbox/pillarbox). Nothing is cropped. coverFill the box completely; crops whichever edges overflow. noneUse intrinsic size. Larger than the box → cropped; smaller → centered with empty space. scale-downLike none if smaller than the box, else like contain.

object-position moves the image inside its box for any fit mode that doesn't fill the box completely. Percent values are anchored to that overflow/underflow space, so 0% 0% pins the image's top-left to the box's top-left and 100% 100% pins the bottom-right. Same syntax as background-position; you can also use lengths like 10px 20px or keywords (top right). It also applies to <video>, <iframe>, and replaced elements like <svg>.