Created
February 16, 2022 02:38
-
-
Save daltonmenezes/9cac0767af3d248eddc61e8a57b2b44d to your computer and use it in GitHub Desktop.
A pixel to rem utility function
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
function pixelToRem(...values: number[]) { | |
return values | |
.reduce((acc, current) => (acc += current / 16 + `rem `), "") | |
.trim(); | |
} | |
pixelToRem(13, 20) // 0.8125rem 1.25rem |
you are a best, champ! 🏆
very nice!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another solution: