Skip to content

Instantly share code, notes, and snippets.

@jeangontijo
Last active June 14, 2018 14:37
Show Gist options
  • Save jeangontijo/6af7e1748360c59bf2b1c576c6962df2 to your computer and use it in GitHub Desktop.
Save jeangontijo/6af7e1748360c59bf2b1c576c6962df2 to your computer and use it in GitHub Desktop.
Aspect Ratio Calculator
<script type="text/javascript">
window.addEventListener("resize", aspectRatio);
function aspectRatio() {
var w = window.innerWidth;
var h = window.innerHeight;
var r = w/10;
var aspect = document.querySelector('pre');
var rounded = Math.round( h/r * 10 ) / 10;
aspect.innerHTML = "<pre style='position:fixed; top: 30px; right: 30px; color: #fff; background: #000; padding: 10px 20px; z-index: 99999999;'>"+ w/r +":"+ rounded +"</pre>";
}
</script>
<pre></pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment