Advertisement
Guest User

Untitled

a guest
May 28th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. // ----
  2. // libsass (v3.1.0)
  3. // ----
  4.  
  5. $default-font-size: 16;
  6.  
  7. @function remove-unit($num) {
  8. @return $num / ($num * 0 + 1);
  9. }
  10. @mixin rem($property, $values) {
  11. $total: length($values);
  12. $px-value: "";
  13. $rem-value: "";
  14.  
  15. @for $i from 1 through $total {
  16. $value: nth($values, $i);
  17.  
  18. // Check if $value is string or not
  19. @if type_of($value) != string{
  20. // convert to REM
  21. $value: remove-unit(nth($values, $i));
  22. $px-value: #{$px-value + $value}px;
  23. $rem-value: #{$rem-value + $value / $default-font-size}rem;
  24. }
  25. @else {
  26. // pass value is string
  27. $value: nth($values, $i);
  28. $px-value: #{$px-value + $value};
  29. $rem-value: #{$rem-value + $value};
  30. }
  31.  
  32. @if $i < $total {
  33. // Set PX
  34. $rem-value: #{$rem-value + " "};
  35. // Set REM
  36. $px-value: #{$px-value + " "};
  37. }
  38. }
  39. #{$property}: $px-value;
  40. #{$property}: $rem-value;
  41. }
  42.  
  43. /* WITH VALUES */
  44. @include rem(padding, 12px 16px);
  45. @include rem(margin, 16 20);
  46.  
  47. /* WITH AUTO */
  48. @include rem(margin, 12px auto);
  49. @include rem(margin, 16 auto);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement