Last active
June 14, 2018 14:37
-
-
Save jeangontijo/6af7e1748360c59bf2b1c576c6962df2 to your computer and use it in GitHub Desktop.
Aspect Ratio Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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