You can do this using pure CSS; no JavaScript needed. This utilizes the (somewhat counterintuitive) fact that padding-top
percentages are relative to the containing block's width. Here's an example:
.wrapper {_x000D_
width: 50%;_x000D_
/* whatever width you want */_x000D_
display: inline-block;_x000D_
position: relative;_x000D_
}_x000D_
.wrapper:after {_x000D_
padding-top: 56.25%;_x000D_
/* 16:9 ratio */_x000D_
display: block;_x000D_
content: '';_x000D_
}_x000D_
.main {_x000D_
position: absolute;_x000D_
top: 0;_x000D_
bottom: 0;_x000D_
right: 0;_x000D_
left: 0;_x000D_
/* fill parent */_x000D_
background-color: deepskyblue;_x000D_
/* let's see it! */_x000D_
color: white;_x000D_
}
_x000D_
<div class="wrapper">_x000D_
<div class="main">_x000D_
This is your div with the specified aspect ratio._x000D_
</div>_x000D_
</div>
_x000D_