Created
February 19, 2015 16:34
-
-
Save Harrisonbro/60e888609e53d5b234ce 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, !important); | |
} | |
.bar { | |
@include rem('margin', 5, something-non-numeric, 2, !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 !important; | |
margin: 5rem !important; } | |
.bar { | |
margin: 80px something-non-numeric 32px !important another-suffix; | |
margin: 5rem something-non-numeric 2rem !important another-suffix; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment