steps() 设置间隔参数,可以实现分步过渡

第一个参数指定了时间函数中的间隔数量(必须是正整数)
第二个参数可选,接受 start 和 end 两个值,指定在每个间隔的起点或是终点发生阶跃变化,默认为 end

steps() 的实现方法:

  1. .heart{
  2.     background-image: url('images/heart-sprite.png');
  3.     -webkit-animation: animate 1s steps(28) infinite;
  4.             animation: animate 1s steps(28) infinite;
  5. }
  6. .star{
  7.     background-image: url('images/star-sprite.png');
  8.     -webkit-animation: animate 1s steps(28) infinite;
  9.             animation: animate 1s steps(28) infinite;
  10. }
  11. @keyframes animate {
  12.     from {
  13.         background-position: 0 0;
  14.     }
  15.     to {
  16.         background-position: -2800px 0;
  17.     }
  18. }

step-start 可以实现与 steps() 效果相同的动画

step-start 等同于 steps(10,start) 动画分成10步,动画执行时为开始左侧端点的部分为开始。
step-end 等同于 steps(10,end) 动画分成10步,动画执行时以结尾端点为开始,默认值为 end

step-start 的实现方法:

  1. .heartTwo{
  2.     background-image: url('images/heart-sprite.png');
  3.     -webkit-animation: animateTwo 1s infinite step-start;
  4.             animation: animateTwo 1s infinite step-start;
  5. }
  6. .starTwo{
  7.     background-image: url('images/star-sprite.png');
  8.     -webkit-animation: animateTwo 1s infinite step-start;
  9.             animation: animateTwo 1s infinite step-start;
  10. }
  11. @keyframes animateTwo {
  12.     0%   {  background-position: 0 0; }
  13.     3.4% {  background-position: -100px 0; }
  14.     6.8% {  background-position: -200px 0; }
  15.     10.2%{  background-position: -300px 0; }
  16.     13.6%{  background-position: -400px 0; }
  17.     17%  {  background-position: -500px 0; }
  18.     20.4%{  background-position: -600px 0; }
  19.     23.8%{  background-position: -700px 0; }
  20.     27.2%{  background-position: -800px 0; }
  21.     30.6%{  background-position: -900px 0; }
  22.     34%  {  background-position: -1000px 0; }
  23.     37.4%{  background-position: -1100px 0; }
  24.     40.8%{  background-position: -1200px 0; }
  25.     44.2%{  background-position: -1300px 0; }
  26.     47.6%{  background-position: -1400px 0; }
  27.     51%  {  background-position: -1500px 0; }
  28.     54.4%{  background-position: -1600px 0; }
  29.     57.8%{  background-position: -1700px 0; }
  30.     61.2%{  background-position: -1800px 0; }
  31.     64.6%{  background-position: -1900px 0; }
  32.     68%  {  background-position: -2000px 0; }
  33.     71.4%{  background-position: -2100px 0; }
  34.     74.8%{  background-position: -2200px 0; }
  35.     78.2%{  background-position: -2300px 0; }
  36.     81.6%{  background-position: -2400px 0; }
  37.     85%  {  background-position: -2500px 0; }
  38.     88.4%{  background-position: -2600px 0; }
  39.     91.8%{  background-position: -2700px 0; }
  40.     95.2%{  background-position: -2800px 0; }
  41.     100% {  background-position: 0 0; }
  42. }

steps(1,start) 等同于 step-startsteps(1,end) 等同于 step-end

动画帧数在线生成:http://tid.tenpay.com/labs/css3_keyframes_calculator.html

最新文章

  1. bzoj 2434 阿狸的打字机 fail树的性质
  2. PN结的形成
  3. Github 安全类Repo收集整理
  4. C# 4.0中dynamic的作用
  5. iOS企业级开发
  6. “合规性”是考核IT运维的重要指标
  7. (收藏)C#实现截屏
  8. 黑马程序员——Foundation之NSString和NSMutableString
  9. 使用notepad++编辑器
  10. 深度剖析WordPress主题结构(转)
  11. 迁移ADT/ANT构建的Android项目至Gradle,a walk through。
  12. iOS应用崩溃日志分析-备用
  13. (一)CodeMirror - 基本应用
  14. Keil C51 与 ARM 并存方法
  15. mfc--使用ShellExecute打开另一个可执行程序
  16. mac下安装 resin 奇葩问题总结
  17. USACO The Castle
  18. 笔记-windbg及时调试
  19. 2018-2019-1 20189203《linux内核原理与分析》第六周作业
  20. vue.js的安装

热门文章

  1. float类型的使用
  2. 浅谈云网融合与SD-WAN
  3. 使用SmartQQ实现的智能回复(Web QQ协议)
  4. vSphere 6.5支持512e,NVMe SSD呢?
  5. UICollectionView 讲解
  6. Application具体解释(一)
  7. 用Meta 取消流量器缓存方便调试
  8. Redis经常使用命令
  9. 腾讯云图片鉴黄集成到C# SQL Server 怎么在分页获取数据的同时获取到总记录数 sqlserver 操作数据表语句模板 .NET MVC后台发送post请求 百度api查询多个地址的经纬度的问题 try{}里有一个 return 语句,那么紧跟在这个 try 后的 finally {}里的 code 会 不会被执行,什么时候被执行,在 return 前还是后? js获取某个日期
  10. sql select(A.B)拼接