Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Keyframes animation doesn't work

Tags:

css

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

like image 603
Dj.Sunrise Avatar asked Aug 01 '26 16:08

Dj.Sunrise


1 Answers

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>
like image 129
Weafs.py Avatar answered Aug 03 '26 07:08

Weafs.py



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!