Skip to content

Instantly share code, notes, and snippets.

@dougkeeling
Created August 31, 2021 17:25
Show Gist options
  • Save dougkeeling/061d7a26bb356963d8fc5b602d131c31 to your computer and use it in GitHub Desktop.
Save dougkeeling/061d7a26bb356963d8fc5b602d131c31 to your computer and use it in GitHub Desktop.
[Convert Font Size to Em] #scss #css
$browser-context: 16;
@function em($pixels, $context: $browser-context) {
@if (unitless($pixels)) {
$pixels: $pixels * 1px;
}
@if (unitless($context)) {
$context: $context * 1px;
}
@return $pixels / $context * 1em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment