Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
SASS REMify
@mixin remify($property, $sizes) {
$pixelSizes: ();
$remSizes: ();
@each $s in $sizes {
$pixelSizes: append($pixelSizes, $s * 1px);
$remSizes: append($remSizes, rem($s));
}
#{$property}: $pixelSizes;
#{$property}: $remSizes;
}
@function rem($size) {
$remSize: $size / 16;
@return $remSize * 1rem;
}
@include remify(font-size, 25);
// Outputs
// font-size: 25px;
// font-size: 1.5625rem;
@include remify(margin, 15 0);
// Outputs
// margin: 15px 0px;
// margin: 0.9375rem 0rem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment