Created
June 8, 2022 12:35
-
-
Save miladd3/e7b922893a6fb628093149b89b796da1 to your computer and use it in GitHub Desktop.
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
@function strip-unit($num) { | |
@return $num / ($num * 0 + 1); | |
} | |
@function convert-to-rem($value, $base-value: $rem-base) { | |
$value: strip-unit($value) / strip-unit($base-value) * 1rem; | |
@if ($value == 0rem) { $value: 0; } // Turn 0rem into 0 | |
@return $value; | |
} | |
@function rem-calc($values, $base-value: $rem-base) { | |
$max: length($values); | |
@if $max == 1 { @return convert-to-rem(nth($values, 1), $base-value); } | |
$remValues: (); | |
@for $i from 1 through $max { | |
$remValues: append($remValues, convert-to-rem(nth($values, $i), $base-value)); | |
} | |
@return $remValues; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment