Created
March 6, 2020 20:59
-
-
Save ericmasiello/4c1e13fdd0cdbcc8d3f10b2c4a354c96 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $base-font-size: 16; | |
| // strips away any unit from a value: e.g. "16px" => 16 | |
| @function strip-unit($number) { | |
| @if type-of($number) == 'number' and not unitless($number) { | |
| @return $number / ($number * 0 + 1); | |
| } | |
| @return $number; | |
| } | |
| @function px-to-rem($size, $base: $base-font-size) { | |
| $pxUnitless: strip-unit($size); | |
| @return #{$pxUnitless / $base}rem; | |
| } | |
| .some-selector { | |
| font-size: px-to-rem(20); | |
| padding: px-to-rem(14) px-to-rem(32); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment