Skip to content

Instantly share code, notes, and snippets.

@Fallenstedt
Created November 20, 2017 22:16
Show Gist options
  • Save Fallenstedt/e407ce04f5e1480894941d2c0450ebc8 to your computer and use it in GitHub Desktop.
Save Fallenstedt/e407ce04f5e1480894941d2c0450ebc8 to your computer and use it in GitHub Desktop.
rem.scss
// Default font size set by browsers 16px
$browser-context: 16;
// Calculates the rem value so it can be applied everywhere;
//
// @param an integer font size in px
// @param an integer reference size in px
// @return a string with rem unit.
//
@function rem($pixels, $context: $browser-context) {
@if (unitless($pixels)) {
$pixels: $pixels * 1px;
}
@if (unitless($context)) {
$context: $context * 1px;
}
@return $pixels / $context * 1rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment