Skip to content

Instantly share code, notes, and snippets.

@gabemeola
Created June 25, 2019 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabemeola/84e06640cf7e0748b86b085933b60cce to your computer and use it in GitHub Desktop.
Save gabemeola/84e06640cf7e0748b86b085933b60cce to your computer and use it in GitHub Desktop.
px to rem
/**
* Returns rem representation of pixel based on root size.
*
* @param {number} px - Pixel Size
* @param {number} [rootSize=16] - Root Font Size
* @returns {string}
*/
export default function pxToRem(px: number, rootSize: number = 16): string {
return `${px / rootSize}rem`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment