3

I am using css3 to animate sprite from the left to right, using Keyframes animation. Anyone help? How to fix this?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<style>
#adam{
    background:url(adam.png);
    width: 120px;
    height: 180px;
    animation: walk-east 1.0s steps(8) infinite;
}
@keyframes walk-east {
    from { background-position: 0px; }
    to { background-position: -960px; }
}
</style>
<body>

<div id="adam"></div>


<body>
</html>

https://www.adamkhoury.com/demo/sprite_sheets/adam.png

Dj.Sunrise
  • 483
  • 5
  • 10
  • 23
  • 1
    What browser are you on? – Weafs.py Jan 11 '15 at 15:23
  • Works pretty fine. Hope you are including the browser prefixes. [Fiddle](http://jsfiddle.net/dvnc0804/) – Harry Jan 11 '15 at 15:23
  • possible duplicate of [Why doesn't \[CSS feature\] work in \[browser\] but works in others?](http://stackoverflow.com/questions/25110510/why-doesnt-css-feature-work-in-browser-but-works-in-others) – Harry Jan 11 '15 at 15:34

1 Answers1

2

You are missing the -webkit- prefix.

Browser compatibility table for @keyframes.

#adam {
  background: url(https://www.adamkhoury.com/demo/sprite_sheets/adam.png);
  width: 120px;
  height: 180px;
  -webkit-animation: walk-east 1.0s steps(8) infinite;
  animation: walk-east 1.0s steps(8) infinite;
}
@-webkit-keyframes walk-east {
  from {
    background-position: 0px;
  }
  to {
    background-position: -960px;
  }
}
@keyframes walk-east {
  from {
    background-position: 0px;
  }
  to {
    background-position: -960px;
  }
}
<div id="adam"></div>
Weafs.py
  • 22,731
  • 9
  • 56
  • 78