Skip to content

Instantly share code, notes, and snippets.

@giovanni-antonio
Last active February 18, 2018 05:11
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 giovanni-antonio/0fc42ee94411d881b567639a026c9cf1 to your computer and use it in GitHub Desktop.
Save giovanni-antonio/0fc42ee94411d881b567639a026c9cf1 to your computer and use it in GitHub Desktop.
Sass Px2Em function
// PX to EM
@function em($pixels, $context: $font-base-size) {
@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