Skip to content

Instantly share code, notes, and snippets.

@shaunbent
Forked from kaelig/SassMeister-input.scss
Created November 15, 2013 17:41
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 shaunbent/7488460 to your computer and use it in GitHub Desktop.
Save shaunbent/7488460 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// 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 {
@if $value == 0 { @return 0; }
@if $value == 'auto' { @return auto; } // added in the option to pass in auto
@return if(unit($value) == px, $value / $baseline * 1rem, $value);
}
}
// Use rem units with px fallback
@mixin rem($properties) {
@each $property, $value in $properties {
@if (type-of($value) == number and $value != 0) {
$value: if(unitless($value), $value * 1px, $value);
}
#{$property}: $value;
#{$property}: rem($value);
}
}
.test {
@include rem((
padding: 20px 0 0px 3vh,
width: 300px,
margin: 20px auto 20px auto,
height: 350px,
line-height: 20px
));
}
.test {
padding: 20px 0 0px 3vh;
padding: 2rem 0 0 3vh;
width: 300px;
width: 30rem;
margin: 20px auto 20px auto;
margin: 2rem auto 2rem auto;
height: 350px;
height: 35rem;
line-height: 20px;
line-height: 2rem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment