-1

The background-image cannot be animated with keyframes like below:

@keyframes kick{
    0%{background-image: url(images/img-man-1.png);}
    25%{background-image: url(images/img-man-2.png);}
    50%{background-image: url(images/img-man-3.png);}
    75%{background-image: url(images/img-man-4.png);}
    100%{background-image: url(images/img-man-5.png);}
}
.img-man{
    animation: kick 1.2s;
    animation-play-state: running;
    animation-iteration-count: infinite;
}

So, is there any method with css3. If it's impossible to do with css3 jquery is welcome.

Navin Rauniyar
  • 10,127
  • 14
  • 45
  • 68

3 Answers3

1

I do believe this is what you're looking for.

eclipsis
  • 1,541
  • 3
  • 20
  • 56
0

With javaScript:

var frames = 3;
var img = document.getElementsByClassName('img-man')[0];
var frame = 0;
var animation = setInterval(function() { 
    if (frame == frames) { clearInterval(animation); return; }
    img.style.background = 'url(images/img-man-'+ frame++ + '.png)';
}, 500);
Alain Jacomet Forte
  • 4,575
  • 6
  • 29
  • 41
0

You can get this effect by using css3 animation and keyframes. Check out this Example.

.img-man
 {
  width: 200px;
  height: 200px;
  animation: kick 10s infinite;
  -webkit-animation: kick 10s infinite;
  background-size:200px 200px;
 }

Also, remove animation-play-state: running; on your code since "running" is the default value see here .

Good Luck!!.