Last active
August 9, 2018 22:06
-
-
Save nevilpaul/5c96e09efffa3acc40cdbd4a218d9935 to your computer and use it in GitHub Desktop.
SCSS/SASS _mixins cross browser (animation,transition,border-radius and box shadow)
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
@mixin animation($loader, $ts, $iterrationcount, $timeFunction) { | |
-webkit-animation: $loader $ts $iterrationcount $timeFunction; | |
-moz-animation: $loader $ts $iterrationcount $timeFunction; | |
-ms-animation: $loader $ts $iterrationcount $timeFunction; | |
-o-animation: $loader $ts $iterrationcount $timeFunction; | |
animation: $loader $ts $iterrationcount $timeFunction; | |
} | |
@mixin scrollbar($width) { | |
::-webkit-scrollbar { | |
width: $width; | |
} | |
::-moz-scrollbar { | |
width: $width; | |
} | |
::-ms-scrollbar { | |
width: $width; | |
} | |
::-o-scrollbar { | |
width: $width; | |
} | |
::scrollbar { | |
width: $width; | |
} | |
} | |
/*all transitions */ | |
@mixin translate($x, $y) { | |
-webkit-transform: translate($x, $y); | |
-moz-transform: translate($x, $y); | |
-ms-transform: translate($x, $y); | |
-o-transform: translate($x, $y); | |
transform: translate($x, $y); | |
} | |
/*all translateX */ | |
@mixin translateX($x) { | |
-webkit-transform: translateX($x); | |
-moz-transform: translateX($x); | |
-ms-transform: translateX($x); | |
-o-transform: translateX($x); | |
transform: translateX($x); | |
} | |
/*all translateY */ | |
@mixin translateY($y) { | |
-webkit-transform: translateY($y); | |
-moz-transform: translateY($y); | |
-ms-transform: translateY($y); | |
-o-transform: translateY($y); | |
transform: translateY($y); | |
} | |
/*all transitions */ | |
@mixin transition($anim, $times, $timeFunction) { | |
-webkit-transition: $anim $times $timeFunction; | |
-moz-transition: $anim $times $timeFunction; | |
-ms-transition: $anim $times $timeFunction; | |
-o-transition: $anim $times $timeFunction; | |
transition: $anim $times $timeFunction; | |
} | |
@mixin keyframes($keyword) { | |
@content; | |
} | |
@mixin default-button($pxl, $type, $color) { | |
@if($pxl==empty) { | |
border: 0; | |
} | |
@content; | |
} | |
/* | |
*@transform 2d mixins | |
*rotate() | |
*scale() | |
*skewX() | |
*skewY() | |
*matrix() | |
* | |
*/ | |
@mixin trans-form($names_trans, $props...) { | |
-webkit-transform: $names_trans+ "(" + $props +")"; | |
-moz-transform: $names_trans+"(" + $props +")"; | |
-ms-transform: $names_trans+"("+ $props +")"; | |
-o-transform: $names_trans+"("+ $props +")"; | |
transform: $names_trans +"("+ $props +")"; | |
} | |
/* | |
*or transform | |
*/ | |
@mixin transform($transformType, $propaties...) { | |
@if $transformType==rotate { | |
-webkit-transform: rotate($propaties); | |
-moz-transform: rotate($propaties); | |
-ms-transform: rotate($propaties); | |
-o-transform: rotate($propaties); | |
transform: rotate($propaties); | |
} | |
@else if $transformType==scale { | |
-webkit-transform: scale($propaties); | |
-moz-transform: scale($propaties); | |
-ms-transform: scale($propaties); | |
-o-transform: scale($propaties); | |
transform: scale($propaties); | |
} | |
@else if $transformType==skewX { | |
-webkit-transform: skewX($propaties); | |
-moz-transform: skewX($propaties); | |
-ms-transform: skewX($propaties); | |
-o-transform: skewX($propaties); | |
transform: skewX($propaties); | |
} | |
@else if $transformType==skewY { | |
-webkit-transform: skewY($propaties); | |
-moz-transform: skewY($propaties); | |
-ms-transform: skewY($propaties); | |
-o-transform: skewY($propaties); | |
transform: skewY($propaties); | |
} | |
@else if $transformType==matrix { | |
$-webkit-transform: matrix($propaties); | |
-moz-transform: matrix($propaties); | |
-ms-transform: matrix($propaties); | |
-o-transform: matrix($propaties); | |
transform: matrix($propaties); | |
} | |
@else if $transformType==translate3d { | |
$-webkit-transform: translate3d($propaties); | |
-moz-transform: translate3d($propaties); | |
-ms-transform: translate3d($propaties); | |
-o-transform: translate3d($propaties); | |
transform: translate3d($propaties); | |
} | |
@else if $transformType==translate { | |
$-webkit-transform: translate($propaties); | |
-moz-transform: translate($propaties); | |
-ms-transform: translate($propaties); | |
-o-transform: translate($propaties); | |
transform: translate($propaties); | |
} | |
} | |
@mixin keyframe($framename) { | |
@-webkit-keyframes #{$framename} { | |
@content; | |
} | |
@-moz-keyframes #{$framename} { | |
@content; | |
} | |
@-ms-keyframes #{$framename} { | |
@content; | |
} | |
@-o-keyframes #{$framename} { | |
@content; | |
} | |
@keyframes #{$framename} { | |
@content; | |
} | |
} | |
//box shadow cross browser | |
@mixin box-shadow($props...) { | |
-webkit-box-shadow: $props; | |
-moz-box-shadow: $props; | |
-ms-box-shadow: $props; | |
-o-box-shadow: $props; | |
box-shadow: $props; | |
} | |
//border-radius cross browser | |
@mixin border-radius($props...) { | |
-webkit-border-radius: $props; | |
-moz-border-radius: $props; | |
-ms-border-radius: $props; | |
-o-border-radius: $props; | |
border-radius: $props; | |
} | |
/* | |
@fontexport with mixins | |
*/ | |
@mixin font-face($name, $src, $woff, $tft, $svg, $weight, $style) { | |
font-family: $name; | |
src: url(#{$src}); | |
/*src: local('☺'), url('fonts/Mohave.woff') format('woff'), url('fonts/Mohave.ttf') format('truetype'), url('fonts/Mohave.svg') format('svg');*/ | |
font-weight: $weight; | |
font-style: $style; | |
} | |
@mixin for($className, $num) { | |
@for $i from 1 through $num { | |
.#{$className}_#{$i} { | |
@content | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment