Last active
October 16, 2015 17:38
-
-
Save tdrach/f9c9fbdb68beaae152bc to your computer and use it in GitHub Desktop.
Standard SCSS Mixins
This file contains 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
@function strip-unit($num) { | |
@return $num / ($num * 0 + 1); | |
} | |
@mixin rem($property, $values...) { | |
$max: length($values); | |
$pxValues: ''; | |
$remValues: ''; | |
@for $i from 1 through $max { | |
$value: strip-unit(nth($values, $i)); | |
$pxValues: #{$pxValues + $value*16}px; | |
@if $i < $max { | |
$pxValues: #{$pxValues + " "}; | |
} | |
} | |
@for $i from 1 through $max { | |
$value: strip-unit(nth($values, $i)); | |
$remValues: #{$remValues + $value}rem; | |
@if $i < $max { | |
$remValues: #{$remValues + " "}; | |
} | |
} | |
#{$property}: $pxValues; | |
#{$property}: $remValues; | |
} | |
// Vendor prefixing | |
@mixin vp($name, $argument) { | |
-webkit-#{$name}: #{$argument}; | |
-ms-#{$name}: #{$argument}; | |
-moz-#{$name}: #{$argument}; | |
-o-#{$name}: #{$argument}; | |
#{$name}: #{$argument}; | |
} | |
// keyframes mixin | |
@mixin keyframes($name) { | |
@-webkit-keyframes #{$name} { | |
@content; | |
} | |
@-moz-keyframes #{$name} { | |
@content; | |
} | |
@-ms-keyframes #{$name} { | |
@content; | |
} | |
@keyframes #{$name} { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment