Last active
August 29, 2015 13:56
-
-
Save jensgro/9184037 to your computer and use it in GitHub Desktop.
CSS3-animation with Bourbon (bourbon.io)
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
<div class="box"></div> |
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
// ---- | |
// Sass (v3.3.0.rc.5) | |
// Compass (v1.0.0.alpha.18) | |
// Bourbon (v3.2.0.beta.1.a) | |
// ---- | |
@import "bourbon/bourbon"; | |
// shorthand version | |
// Animation shorthand works the same as the CSS3 animation shorthand | |
.box:hover { | |
@include animation(scale 1.0s ease-in, slide 2.0s ease); | |
} | |
// long version | |
/* | |
.box:hover { | |
@include animation-name(scale, slide); | |
@include animation-duration(2s); | |
@include animation-timing-function(ease); | |
@include animation-iteration-count(infinite); | |
} | |
*/ | |
@include keyframes(scale) { | |
0%, 100% { | |
@include transform(scale(1)); | |
} | |
50% { | |
@include transform(scale(2)); | |
} | |
} | |
@include keyframes(slide) { | |
0%, 100% { | |
left: 0; | |
} | |
50% { | |
left: 100%; | |
} | |
} | |
/* just for demo */ | |
body {padding: 40px;} | |
.box { | |
width: 50px; | |
height: 50px; | |
background: #a20000; | |
border-radius: 50%; | |
} |
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
.box:hover { | |
-webkit-animation: scale 1s ease-in, slide 2s ease; | |
-moz-animation: scale 1s ease-in, slide 2s ease; | |
animation: scale 1s ease-in, slide 2s ease; | |
} | |
/* | |
.box:hover { | |
@include animation-name(scale, slide); | |
@include animation-duration(2s); | |
@include animation-timing-function(ease); | |
@include animation-iteration-count(infinite); | |
} | |
*/ | |
@-webkit-keyframes scale { | |
0%, 100% { | |
-webkit-transform: scale(1); | |
} | |
50% { | |
-webkit-transform: scale(2); | |
} | |
} | |
@-moz-keyframes scale { | |
0%, 100% { | |
-moz-transform: scale(1); | |
} | |
50% { | |
-moz-transform: scale(2); | |
} | |
} | |
@keyframes scale { | |
0%, 100% { | |
transform: scale(1); | |
} | |
50% { | |
transform: scale(2); | |
} | |
} | |
@-webkit-keyframes slide { | |
0%, 100% { | |
left: 0; | |
} | |
50% { | |
left: 100%; | |
} | |
} | |
@-moz-keyframes slide { | |
0%, 100% { | |
left: 0; | |
} | |
50% { | |
left: 100%; | |
} | |
} | |
@keyframes slide { | |
0%, 100% { | |
left: 0; | |
} | |
50% { | |
left: 100%; | |
} | |
} | |
/* just for demo */ | |
body { | |
padding: 40px; | |
} | |
.box { | |
width: 50px; | |
height: 50px; | |
background: #a20000; | |
border-radius: 50%; | |
} |
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
<div class="box"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment