I'm trying to create a 16:9 canvas which remains 16:9 regardless of screen size. It works! But only in one direction...
function ratio () {
var w = window.innerWidth;
var newH = w * 0.5625;
document.getElementById('design').style.height = (newH + 'px');
}
window.onload = ratio;
window.onresize = ratio;
So it works when the window's height is too large, but not when the width is too large. My tiny brain can't fathom how to make it work the other way round - when the window is too wide.
I'm aware there's a CSS workaround with padding, but that doesn't work in my case - and I'd prefer to use JS anyway.
FYI.. here's the page: https://clever-carbon.webflow.io/