[Html5基础训练]animation的step使用方法

html 复制代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Sprite Demo</title>
    <style>
      #an {
        width: 128px;
        height: 128px;
        background: url(img/spriteB.png);        
        animation: move infinite 4s steps(8,end);
      }
      /* -254,-384  x-1152  1024-128=    896 */
      @keyframes move {
        0% {
          background-position:0 -256px;
        }
        50% {
          background-position:-1024px -256px;
        } 
        50.001% {
          background-position:0 -384px;
        }
        100% {
          background-position:-1024px -384px;
        }        
        
      }
    </style>
  </head>
  <body>
    <div id="an"></div>
  </body>
</html>

SpriteB图片下载:

相关推荐
梁正雄1 分钟前
Python前端-2-css基础
前端·python·html
Mr Xu_2 分钟前
巧用多背景图层打造精美 CSS 背景 —— 基于 SVG 的视觉合成技巧
前端·css
小杨勇敢飞6 分钟前
npm 安装 @openai/codex 后无法调用 codex 命令的完整解决过程:‘codex‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
前端·npm·node.js
JEECG官方17 分钟前
JeecgBoot低代码平台 Qiankun 微前端集成指南:主应用配置全流程
前端
JEECG官方18 分钟前
JeecgBoot低代码平台从 WPS 切换到 OnlyOffice 的开发配置指南
前端
lichenyang45320 分钟前
虚拟 DOM、Diff 算法与 Fiber
前端·javascript·面试
打酱油的D25 分钟前
前端工程师转 AI Agent 工程师,先把后端能力补上
前端
lclcooky28 分钟前
Spring 核心技术解析【纯干货版】- Ⅶ:Spring 切面编程模块 Spring-Instrument 模块精讲
前端·数据库·spring
angerdream40 分钟前
最新版vue3+TypeScript开发入门到实战教程之学会vue3第一步必是setup语法糖
前端·vue.js
angerdream41 分钟前
最新版vue3+TypeScript开发入门到实战教程之学会vue3真正的响应式数据
javascript·vue.js