CSS3关键帧动画不起作用

时间:2015-01-11 15:20:38

标签: css css3

我使用css3使用Keyframes动画从左到右动画精灵。有人帮吗?如何解决这个问题?

<!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

1 个答案:

答案 0 :(得分:2)

您缺少-webkit-前缀。

<强> Browser compatibility table for @keyframes

&#13;
&#13;
#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;
  }
}
&#13;
<div id="adam"></div>
&#13;
&#13;
&#13;