Experiments in fixed aspect ratios is a handy CSS technique from Stephanie Liu for displaying video embeds in a responsive website without losing their aspect ratio.
The HTML:
<div class="container">
<iframe class="embed"></iframe>
</div>
The CSS:
Last updated: 13 Jun 2021.container { position: relative; width: 100%; height: 0; padding-top: 56.25% // 9 / 16 * 100% }.embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }