I'm trying to figure out how to create a div that has a set aspect ratio (such as 4:3) and automatically resizes itself (i.e. width and height check link below) when resizing the window, without ever changing the ratio. The div should behave exactly like the video in the following jsfiddle, which I created using the object-fit property:
.wrapper video {
object-fit: contain;
width:100%;
height:100%;
}
here the jsfiddle: Fiddle
I realise it may sound like a trivial problem, but all solutions I have found so far were only able to resize a fixed-ratio div based on the window's width. Therefore, please be sure check out what happens when you minify the window's height in the jsfiddle. While using as much space as possible, the div should never leak out of the screen - neither on the right, nor on the bottom.
EDIT: I'm looking for a solution that takes into account the window's width AND height. The links posted so far are only taking into account the window's width.