I have an image that has these styles:
<img src="images/head-tails.gif" class="graphs" />
.graphs {
-webkit-transition: all 2s ease;
-moz-transition: all 2s ease;
-o-transition: all 2s ease;
transition: all 2s ease;
/* -webkit-animation:animated 5s infinite; */
/* -moz-animation:animated 5s infinite; */
/* -o-animation:animated 5s infinite; */
/* animation:animated 5s infinite; */
}
.graphs:hover {
-webkit-transform: rotateY(360deg);
-moz-transform: rotateY(360deg);
-o-transform: rotateY(360deg);
transform: rotateY(360deg);
}
So when I hover over the image it rotates 360 degrees, like a coin. What I would like to make though is when the page loads, the image will do this animation (the rotation) infinitely, without need to hover over my mouse. How I can make this work?
You can use keyframe animation for this. Write like this:
Check this http://jsfiddle.net/ktPev/1/
Use keyframe animations instead. Uncomment the commented code and change the
animation-timing-function
tolinear
. Like thisanimation: animated 5s linear infinite;
. Then define the keyframe animation, for example like this (I've used -webkit- in my example):and it should work!
Here's a DEMO