I am trying to set the aspect ratio of a div to portrait (9:16) like this..
.ratio {
position: relative;
height: 0;
width: 100%;
background: teal;
padding-bottom: 177.77%;
}
<div class="ratio">
16:9
</div>
This is working as expected, but I am now wanting to make it so that it has a maximum height of 100% of the viewport.
I am trying to make sure it fits exactly onto the screen whilst keeping the aspect ratio and not introducing scrollbars.
What's my best approach?