Skip to content

Commit

Permalink
Add rem mixin for px fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
kylefiedler committed Aug 3, 2013
1 parent 74bcdc5 commit 7128644
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/_bourbon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
@import "addons/html5-input-types";
@import "addons/position";
@import "addons/prefixer";
@import "addons/rem";
@import "addons/retina-image";
@import "addons/size";
@import "addons/timing-functions";
Expand Down
33 changes: 33 additions & 0 deletions app/assets/stylesheets/addons/_rem.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@mixin rem($property, $size, $base: $em-base) {
@if not unitless($base) {
$base: strip-units($base);
}

$unitless_values: ();
@each $num in $size {
@if not unitless($num) {
@if unit($num) == "em" {
$num: $num * $base;
}

$num: strip-units($num);
}

$unitless_values: append($unitless_values, $num);
}
$size: $unitless_values;

$pixel_values: ();
$rem_values: ();
@each $value in $pxval {
$pixel_value: $value * 1px;
$pixel_values: append($pixel_values, $pixel_value);

$rem_value: ($value / $base) * 1rem;
$rem_values: append($rem_values, $rem_value);
}

#{$property}: $pixel_values;
#{$property}: $rem_values;
}

0 comments on commit 7128644

Please sign in to comment.