Created
February 19, 2015 16:33
-
-
Save Harrisonbro/96d837adb92221b7a397 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// libsass (v3.1.0) | |
// ---- | |
@function strip-unit($num) { | |
@if type-of($num) == "number" { | |
@return $num / ($num * 0 + 1); | |
} @else { | |
@warn "Not a number value: #{num}"; | |
@return $num; | |
} | |
} | |
@mixin rem($property, $values...) { | |
$max: length($values); | |
$suffix: ""; | |
$px-values: ""; | |
$rem-values: ""; | |
@for $i from 1 through $max { | |
@if type-of(nth($values, $i)) == "number" { | |
$value: strip-unit(nth($values, $i)); | |
$px-values: #{$px-values + $value*16}px; | |
} @else { | |
$px-values: #{$px-values + nth($values, $i)}; | |
} | |
@if $i < $max { | |
$px-values: #{$px-values + " "}; | |
} | |
} | |
@for $i from 1 through $max { | |
@if type-of(nth($values, $i)) == "number" { | |
$value: strip-unit(nth($values, $i)); | |
$rem-values: #{$rem-values + $value}rem; | |
} @else { | |
$rem-values: #{$rem-values + nth($values, $i)}; | |
} | |
@if $i < $max { | |
$rem-values: #{$rem-values + ' '}; | |
} | |
} | |
#{$property}: $px-values + $suffix; | |
#{$property}: $rem-values + $suffix; | |
} | |
.foo { | |
@include rem('margin', 5, 2, any-suffix, !important, another-suffix); | |
} |
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
.foo { | |
margin: 80px 32px any-suffix !important another-suffix; | |
margin: 5rem 2rem any-suffix !important another-suffix; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment