Lock ratio with pure css
You can use this technique for pretty much anything that doesn't maintain aspect ratio in a browser. Handy for responsive layouts :D
HTML
<div class="lock-ratio">
<img src="http://placehold.it/640x360">
<iframe src="//www.youtube.com/embed/ODFSznljMpA?modestbranding=1&showinfo=0&autohide=1" frameborder="0" allowfullscreen></iframe>
</div>
CSS
.lock-ratio{
width: 100%;
position: relative;
}
.lock-ratio img{
width: 100%;
height: auto;
}
.lock-ratio iframe{
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
width: 100%;
height: 100%;
}
JavaScript
// No JS required!