JSFiddle - React, Tailwind, and code Playground
by mihaibirsan
HTML
<html>
<head>
<title>CSS Aspect Fit</title>
</head>
<body>
<div class="viewport">
<p>
This should be a 16:9 viewport that fits the window.
</p>
<img src="" alt="" />
</div>
</body>
</html>
CSS
body {
width: 100vw;
height: 100vh;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
background-color: white;
font-size: min(1vw, 1.778vh);
}
div.viewport {
width: 100em;
height: 56.25em;
background-color: lightblue;
}
div.viewport > p {
font-size: 3em;
text-align: center;
}