-
-
Save fmal/5025632 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
| $main-font-size: 16px; | |
| @mixin x-rem($property, $values) { | |
| // Empty list for all values in px | |
| $px-values: (); | |
| $rem-values: (); | |
| // Iterate over entries | |
| @each $value in $values { | |
| // If the value is zero, return 0 | |
| @if $value == 0 { | |
| $px-values: append($px-values, $value); | |
| $rem-values: append($rem-values, $value); | |
| // If the value is not zero, convert it from px to rem | |
| } @else { | |
| $px-values: append($px-values, ($value * $main-font-size) ); | |
| $rem-values: append($rem-values, #{$value}rem); | |
| } | |
| } | |
| // Return the property and its list of converted values | |
| #{$property}: #{$px-values}; | |
| #{$property}: #{$rem-values}; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment