Skip to content

Instantly share code, notes, and snippets.

@connoro7
Created October 11, 2022 19:15
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 connoro7/0e071e8f49be9e969dc1232c4d6838b2 to your computer and use it in GitHub Desktop.
Save connoro7/0e071e8f49be9e969dc1232c4d6838b2 to your computer and use it in GitHub Desktop.
Safely converts rem units from base-16 to base-10
/* Converts rem units from base-16 to base 10. */
/* No more 76.5px / 16 = 4.78rem, or 25px / 16 = 1.56rem, or 2.2rem * 16 = 35.2px */
/* 2.5rem becomes 25px */
/* 7.65rem becomes 76.5px */
:root {
/* Adjusts rem to base-10 equivalent */
font-size: 62.5%;
}
body {
/* Adjusts *displayed* font size for accessibility, but rem remains in base-10 */
font-size: 1.6rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment