JSFiddle - React, Tailwind, and code Playground
HTML
<div class="parent">
<div class="child">
content that is not images...
</div>
</div>
CSS
html,body {
height: 100%;
}
.parent {
height: 100%;
width: 100%;
border-style: solid;
border-width: 2px;
border-color: black;
/* to center */
display: flex;
align-items: center;
justify-content: center;
}
.child {
width: 100%;
/* 16:9 aspect ratio = 9 / 16 = 0.5625 = padding-bottom*/
padding-bottom: 56.25%;
background: blue;
}
@media (min-aspect-ratio: 16/9) {
.parent>img {
height: 100%;
/* make the img's width 100% of the height of .container */
}
.child {
height: 100%;
/*16:9 aspect ratio = 9 / 16 = 177.77 = width*/
width: 177.77vh;
padding: 0;
margin: 0px;
background: red;
}
}