<main>
  <p>A video!</p>
  <iframe width="560" height="315" src="https://www.youtube.com/embed/Vbg81kc56FU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen style="--aspect-ratio: 315 / 560;"></iframe>
  <p>Nice! Aspect Ratio!</p>
</main>
:root {
  --main-width: 60vw;
}

main {
  height: 100vh;
  max-width: var(--main-width);
  margin: 0 auto;
  padding: 1rem;
  background-color: rgb(238, 238, 238);
}

iframe {
  width: 100%;
  height: calc(var(--main-width) * var(--aspect-ratio));
}

* {
  margin: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: #eee;
  background-image: url('data:image/svg+xml,%3Csvg width="52" height="26" viewBox="0 0 52 26" xmlns="http://www.w3.org/2000/svg"%3E%3Cg fill="none" fill-rule="evenodd"%3E%3Cg fill="%239C92AC" fill-opacity="0.4"%3E%3Cpath d="M10 10c0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6h2c0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4 3.314 0 6 2.686 6 6 0 2.21 1.79 4 4 4v2c-3.314 0-6-2.686-6-6 0-2.21-1.79-4-4-4-3.314 0-6-2.686-6-6zm25.464-1.95l8.486 8.486-1.414 1.414-8.486-8.486 1.414-1.414z" /%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
}
/*
 * https://css-tricks.com/fluid-width-video/#comment-1755014
 */
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.