逐帧动画demo


用这一张图实现一个在跑的猎豹的动画

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .container{
            width: 100px;
            height: 100px;
            border: 1px solid red;
            background: url(./animal.png) no-repeat;
            animation: run 1s infinite;
            animation-timing-function: steps(1);
            /* steps(1) 是一种特定的时间函数,它表示动画将在每个关键帧之间离散地切换,就像一步一步前进一样。 */
            /* 动画会在每个关键帧之间立即切换,而不会经过过渡动画 */
        }
        @keyframes run{
            0%{
                background-position: 0 0;
            }
            12.5%{
                background-position: -100px 0;
            }
            25%{
                background-position: -200px 0;
            }
            37.5%{
                background-position: -300px 0;
            }
            50%{
                background-position: 0 -100px;
            }
            62.5%{
                background-position: -100px -100px;
            }
            75%{
                background-position: -200px -100px;
            }
            87.5%{
                background-position: -300px -100px;
            }
            100%{
                background-position: 0 0;
            }
        }
    </style>
</head>
<body>
    <div class="container">
    </div>
</body>
</html>

steps(1) 是一种特定的时间函数,它表示动画将在每个关键帧之间离散地切换,就像一步一步前进一样。

动画会在每个关键帧之间立即切换,而不会经过过渡动画

图片和代码文件点击获取

相关推荐
Filotimo_3 天前
2.CSS3.(3).html
前端·css3
Pu_Nine_94 天前
教程: 在网页中利用原生CSS实现3D旋转动画
css·3d·css3
Ares-Wang5 天前
CSS3》》 transform、transition、translate、animation 区别
前端·css·css3
西洼工作室11 天前
浏览器事件循环与内存管理可视化
前端·javascript·css·css3
皮蛋瘦肉粥_12113 天前
pink老师html5+css3day06
前端·css3·html5
whltaoin13 天前
中秋赏月互动页面:用前端技术演绎传统节日之美
前端·javascript·html·css3·中秋主题前端
皮蛋瘦肉粥_12118 天前
pink老师html5+css3day02
前端·css3·html5
qianmo202118 天前
基于any2web+deepseek实现对三角函数定义的理解
css·html·css3
我不是程序媛lisa20 天前
前端正确处理“文字溢出”的思路与最佳实践
前端·css3
患得患失9491 个月前
【ThreeJs】【HTML载入】Three.js 中的 CSS2DRenderer 与 CSS3DRenderer 全面解析
javascript·html·css3