Skip to content

Instantly share code, notes, and snippets.

@hanspagel
Last active February 11, 2016 15:31
Show Gist options
  • Save hanspagel/066e49c1486cafd8b167 to your computer and use it in GitHub Desktop.
Save hanspagel/066e49c1486cafd8b167 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
$rem-baseline: 16px !default;
// Function: Pixel to REM
@function rem($values...) {
$result: ();
$separator: list-separator($values);
@each $value in $values {
@if type-of($value) == "number" and unit($value) == "px" {
$result: append($result, $value / ($rem-baseline / 1rem), $separator);
} @else if type-of($value) == "list" {
$result: append($result, rem($value...), $separator);
} @else {
$result: append($result, $value, $separator);
}
}
@return $result;
}
// Examples
.example {
font-size: rem(10px);
text-shadow: rem(1px 1px #eee, -1px -1px #eee);
padding: rem(10px 0 1px 3%);
}
.example {
font-size: 0.625rem;
text-shadow: 0.0625rem 0.0625rem #eee, -0.0625rem -0.0625rem #eee;
padding: 0.625rem 0 0.0625rem 3%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment