Last active
October 8, 2020 04:09
-
-
Save christoshrousis/0fbaaea1f4171c5da20b8d5d2dd59e39 to your computer and use it in GitHub Desktop.
CSS Pixels to Rem Conversion using Browser Context. SCSS & SASS
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
// The base fontsize you want to use. | |
$browser-context: 16 | |
@function rem($pixels, $context: $browser-context) | |
@if unitless($pixels) | |
$pixels: $pixels * 1px | |
@if unitless($context) | |
$context: $context * 1px | |
@return $pixels / $context * 1rem |
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
// The base fontsize you want to use. | |
$browser-context: 16; | |
@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