Skip to content

Instantly share code, notes, and snippets.

@siriokun
Created July 31, 2013 10:38
Show Gist options
  • Save siriokun/6121032 to your computer and use it in GitHub Desktop.
Save siriokun/6121032 to your computer and use it in GitHub Desktop.
Spin Animation in CSS3
.gear {
position: absolute;
width: 60px;
height: 60px;
background: url("/images/gear.png") no-repeat;
background-size: 100% 100%;
z-index: 2;
-webkit-animation-name: gearSpin;
-moz-animation-name: gearSpin;
-ms-animation-name: gearSpin;
-o-animation-name: gearSpin;
animation-name: gearSpin;
-webkit-animation-duration: 3s;
-moz-animation-duration: 1.5s;
-ms-animation-duration: 1.5s;
-o-animation-duration: 1.5s;
animation-duration: 1.5s;
-moz-animation-timing-function: linear;
-ms-animation-timing-function: linear;
-o-animation-timing-function: linear;
animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-ms-animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
@keyframes gearSpin {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
25% {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
50% {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
75% {
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
100% {
-webkit-transform: rotate(359deg);
-moz-transform: rotate(359deg);
-ms-transform: rotate(359deg);
-o-transform: rotate(359deg);
transform: rotate(359deg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment