-
-
Save erickjones/02444d302ee3d73953e1 to your computer and use it in GitHub Desktop.
SASS REMify
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
@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