Skip to content

Instantly share code, notes, and snippets.

@marciobarrios
Created March 20, 2014 23:29
Show Gist options
  • Save marciobarrios/9676288 to your computer and use it in GitHub Desktop.
Save marciobarrios/9676288 to your computer and use it in GitHub Desktop.
html {
font-size: 62.5%; /* 1 */
}
@function parseInt($n) { /* 2 */
@return $n / ($n * 0 + 1);
}
@mixin rem($property, $values) {
$px : (); /* 3 */
$rem: (); /* 3 */
@each $value in $values { /* 4 */
@if $value == 0 or $value == auto { /* 5 */
$px : append($px , $value);
$rem: append($rem, $value);
}
@else {
$unit: unit($value); /* 6 */
$val: parseInt($value); /* 6 */
@if $unit == "px" { /* 7 */
$px : append($px, $value);
$rem: append($rem, ($val / 10 + rem));
}
@if $unit == "rem" { /* 7 */
$px : append($px, ($val * 10 + px));
$rem: append($rem, $value);
}
}
}
@if $px == $rem { /* 8 */
#{$property}: $px; /* 9 */
} @else {
#{$property}: $px; /* 9 */
#{$property}: $rem; /* 9 */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment