Created
June 10, 2015 21:21
-
-
Save pgarciacamou/3d46bcc19621f46f03d5 to your computer and use it in GitHub Desktop.
Convert pixels to rems with JavaScript
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
var toRem = (function(){ | |
var fontSize = parseFloat(window.getComputedStyle(document.querySelector("html"), null).getPropertyValue('font-size')); | |
return function toRem(px){ | |
return px/fontSize; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment