Last active
March 11, 2020 13:54
-
-
Save CristinaSolana/5483938 to your computer and use it in GitHub Desktop.
SCSS Mixin for rem + px fallback on multiple properties and property lists
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
// Global Vars | |
$basefontsize: 16 !default; | |
// Mixins | |
// input pixel value unitless: 8 vs 8px | |
// ex. @include rem(padding, 8 12 16 24) | |
@mixin rem($property, $px: $basefontsize) { | |
$pxvalues: null; | |
$remvalues: null; | |
@each $pxvalue in $px { | |
$pxvalues: append($pxvalues, ($pxvalue)+px); | |
$remvalues: append($remvalues, ($pxvalue/$basefontsize)+rem); | |
} | |
#{$property}: $pxvalues; | |
#{$property}: $remvalues; | |
} | |
// SCSS | |
.foo { | |
@include rem(padding, 8 16 16); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment