Created
November 20, 2017 22:16
-
-
Save Fallenstedt/e407ce04f5e1480894941d2c0450ebc8 to your computer and use it in GitHub Desktop.
rem.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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