Skip to content

Instantly share code, notes, and snippets.

@michael-benin-CN
Forked from drublic/rem-fallback.less
Created August 1, 2014 18:58
Show Gist options
  • Save michael-benin-CN/c7a3f6354909665c4a33 to your computer and use it in GitHub Desktop.
Save michael-benin-CN/c7a3f6354909665c4a33 to your computer and use it in GitHub Desktop.
@main-font-size: 16px;
.x-rem (@property, @value) {
// This is a workaround, inspired by https://github.com/borodean/less-properties
@px-fallback: @value * @main-font-size;
-: ~`(function () { return ';@{property}: @{px-fallback}'; }())`;
-: ~`(function () { return ';@{property}: @{value}rem'; }())`;
}
.some-class {
.x-rem(font-size, 1.4);
}
$main-font-size: 16px;
@mixin x-rem ($property, $value) {
#{$property}: $value * $main-font-size;
#{$property}: #{$value}rem;
}
.some-class {
@include x-rem(font-size, 1.4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment