Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ----
- // libsass (v3.1.0)
- // ----
- $default-font-size: 16;
- @function remove-unit($num) {
- @return $num / ($num * 0 + 1);
- }
- @mixin rem($property, $values) {
- $total: length($values);
- $px-value: "";
- $rem-value: "";
- @for $i from 1 through $total {
- $value: nth($values, $i);
- // Check if $value is string or not
- @if type_of($value) != string{
- // convert to REM
- $value: remove-unit(nth($values, $i));
- $px-value: #{$px-value + $value}px;
- $rem-value: #{$rem-value + $value / $default-font-size}rem;
- }
- @else {
- // pass value is string
- $value: nth($values, $i);
- $px-value: #{$px-value + $value};
- $rem-value: #{$rem-value + $value};
- }
- @if $i < $total {
- // Set PX
- $rem-value: #{$rem-value + " "};
- // Set REM
- $px-value: #{$px-value + " "};
- }
- }
- #{$property}: $px-value;
- #{$property}: $rem-value;
- }
- /* WITH VALUES */
- @include rem(padding, 12px 16px);
- @include rem(margin, 16 20);
- /* WITH AUTO */
- @include rem(margin, 12px auto);
- @include rem(margin, 16 auto);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement