Forked from chriseppstein/SassMeister-input.scss
Last active
December 28, 2015 19:39
-
-
Save vinayraghu/7551674 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
// ---- | |
// Sass (v3.3.0.rc.1) | |
// Compass (v0.13.alpha.10) | |
// ---- | |
// Transform a value into rem | |
// Assuming baseline is set to 10px on :root/html | |
@function rem($value, $baseline: 10px) { | |
@if type-of($value) == list { | |
$result: (); | |
@each $e in $value { | |
$result: append($result, rem($e)); | |
} | |
@return $result; | |
} @else { | |
@return if(($value / $value) > 0, if(unit($value) == px, $value / $baseline * 1rem, $value), 0); | |
} | |
} | |
// Use rem units with px fallback | |
@mixin rem($properties) { | |
@each $property, $value in $properties { | |
#{$property}: $value; | |
#{$property}: rem($value); | |
} | |
} | |
.test { | |
@include rem(( | |
padding: 20px, | |
width: 300px, | |
height: 350px, | |
line-height: 20px, | |
margin: 0 10px 3vh 0px | |
)); | |
} |
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
.test { | |
padding: 20px; | |
padding: 2rem; | |
width: 300px; | |
width: 30rem; | |
height: 350px; | |
height: 35rem; | |
line-height: 20px; | |
line-height: 2rem; | |
margin: 0 10px 3vh 0px; | |
margin: 0 1rem 3vh 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Final example returns 0 instead of 0rem
Does not remove the unit for the px fallback