[ BLOG ]For Product Designers · 5 min read

Responsive Video Without Cropping or Stretching

Published

A responsive video should fit the page without cutting off a face, a slide, or the edge of a screen recording. Let its height follow the original proportions when the layout allows it. If the design requires a fixed shape, use object-fit: contain and leave room around the picture.

Check whether the missing edges are in the file

Open the video’s actual file URL outside the page and compare the same frame. If the edges are missing there too, the file may already have been cropped during recording or export. CSS cannot recover those pixels; you need the original recording or a different edit.

If the full picture appears in the file but not on the page, inspect the video and its parent in browser developer tools. Look for a fixed height, object-fit: cover, or a parent with overflow: hidden that clips a taller child. Temporarily disable those rules to find which one causes the crop.

Let the video determine its height

For an article or tutorial, the simplest layout is usually a video that fills the available width and keeps its original proportions. This example uses a landscape recording:

<video class="lesson-video" controls playsinline preload="none"
  width="1280" height="720" poster="/media/lesson-preview.webp">
  <source src="/media/lesson.mp4" type="video/mp4" />
  <track kind="captions" src="/media/lesson.en.vtt"
    srclang="en" label="English" />
</video>
.lesson-video {
  display: block;
  width: 100%;
  height: auto;
}

Replace the paths with your files. Set the HTML width and height to the video’s actual display dimensions. They describe its proportions; the CSS controls its size on the page. A portrait recording needs portrait dimensions. Do not leave the landscape numbers in place when replacing the source.

height: auto lets the height follow the video’s aspect ratio as its width changes. MDN explains how intrinsic aspect ratios affect sizing. Avoid adding a fixed height or a conflicting max-height to this pattern.

The poster is the still image shown before playback. Choose one with the same proportions as the recording so the preview and moving picture agree. The video poster guide covers choosing and adding that image. Supply a real caption file when the video contains speech or sounds needed to understand it; the paths above are placeholders.

Keep the whole picture inside a fixed box

A grid of videos may need matching player shapes even when the recordings differ. Give the wrapper the required shape and fit each video inside it:

<div class="video-frame">
  <video controls playsinline preload="none"
    poster="/media/lesson-preview.webp">
    <source src="/media/lesson.mp4" type="video/mp4" />
    <track kind="captions" src="/media/lesson.en.vtt"
      srclang="en" label="English" />
  </video>
</div>
.video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #171717;
}

.video-frame > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

The wrapper uses 16:9 as a design choice, not a requirement for web video. Its height is calculated from its width using CSS aspect-ratio. Leave that height automatic; specifying both dimensions would override the ratio’s role in sizing the wrapper.

A portrait clip in this landscape box has space on its sides. That space is necessary to show the entire picture without changing its proportions. If the resulting picture is too small to read, give that clip a taller layout instead of enlarging it until the edges disappear. This matters when reusing vertical social videos.

MDN’s object-fit reference describes the alternatives: contain preserves the whole picture, cover fills the box by cropping when the proportions differ, and fill can stretch the picture. Moving object-position changes which area stays visible under a crop; it cannot make the whole frame fit.

Check the page before and during playback

  • Resize the page through narrow and wide layouts. Check that neither the video nor its wrapper extends beyond the content column.
  • Compare the poster, paused frame, and playing video. Watch for a height jump or a preview that promises content the video crops out.
  • Try portrait, square, and landscape sources if the component accepts uploads. Check controls and captions on an actual phone, including fullscreen playback.
  • Check small text at the size viewers will see it. Keeping every pixel in frame does not make a dense recording readable. The screen recording guide covers capture and export decisions when scaling alone is insufficient.

These examples apply to an HTML video element. An embedded YouTube or Vimeo player uses an iframe; object-fit does not control the picture inside it. Use that provider’s supported player settings and check the framing in the uploaded source.

Resizing the player also leaves the downloaded video file unchanged. If loading is slow after the layout is fixed, inspect the media request separately rather than expecting a smaller CSS width to reduce the transfer.