Created
April 19, 2013 09:43
-
-
Save mrakowski0/5419272 to your computer and use it in GitHub Desktop.
Mixin that accepts a property and at least one value, then returns it as rem with px fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| html { | |
| font-size: 62.5%; | |
| } | |
| .element { | |
| @include rem-fallback(padding, 50, 30); | |
| @include rem-fallback(margin, 120, auto); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @mixin rem-fallback($property, $top, $right: $top, $bottom: $top, $left: $right) { | |
| @if $top == $bottom { | |
| @if $top == $right { | |
| #{$property}: $top + px; | |
| #{$property}: ($top / 10) + rem; | |
| } | |
| @else { | |
| @if $right == auto { | |
| #{$property}: $top + px auto; | |
| #{$property}: ($top / 10) + rem auto; | |
| } | |
| @else { | |
| #{$property}: $top + px $right + px; | |
| #{$property}: ($top / 10) + rem ($right / 10) + rem; | |
| } | |
| } | |
| } | |
| @else { | |
| #{$property}: $top + px $right + px $bottom + px $left + px; | |
| #{$property}: ($top / 10) + rem ($right / 10) + rem ($bottom / 10) + rem ($left / 10) + rem; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment