html - 定格动画 CSS

标签 html css css-animations

我正在制作一只正在奔跑的猫的定格动画。我已经准备好了所有的幻灯片。但它似乎不能正常工作:

div {
  animation: run 1s steps(10) infinite;
  -webkit-animation: run 1s steps(10) infinite;
  background: url(http://stash.rachelnabors.com/img/codepen/tuna_sprite.png) 0 0; 
  background-repeat: no-repeat;
  height: 200px;
  width: 400px;
}

@keyframes run {  
  0% {background-position: 100% 0; } 
  100% {background-position: 100% -2591px; }
}
@-webkit-keyframes run {  
  0% {background-position: 100% 0; } 
  100% {background-position: 100% -2591px; }
}
<div></div>

最佳答案

实际上您有 13 张幻灯片。所以放steps(13)

div {
  animation: run 1s steps(13) infinite;
  -webkit-animation: run 1s steps(13) infinite;
  background: url(http://stash.rachelnabors.com/img/codepen/tuna_sprite.png) 0 0; 
  background-repeat: no-repeat;
  height: 200px;
  width: 400px;
}

@keyframes run {  
  0% {background-position: 100% 0; } 
  100% {background-position: 100% -2591px; }
}
@-webkit-keyframes run {  
  0% {background-position: 100% 0; } 
  100% {background-position: 100% -2591px; }
}
<div></div>

关于html - 定格动画 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27835008/

相关文章:

html - 具有边框半径的元素之间的奇怪空间及其绝对定位的伪内容

jQuery 设置交替颜色行

css - 在 CSS3 中使用旋转过渡动画关键帧

html - 关键帧动画未在 Safari 中启动

html - 下拉菜单问题 HTML CSS 后面的图像

php mysql 注册表

javascript - 使用 javascript/jquery 单击 DOM 元素后更改地址栏中的 URL

html - 如何在 Bootstrap 3 的链表组项中添加下拉按钮?

css - 带 CSS 3 过渡的滑动门按钮

php - 如何更新图像?