Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Harrisonbro
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Harrisonbro/4470a40ea076b4e54de6 to your computer and use it in GitHub Desktop.
Save Harrisonbro/4470a40ea076b4e54de6 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// 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);
}
.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