css实现奔跑的效果


<!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>
        .box {
            width: 180px;
            height:300px;
            border:2px solid #ccc;
            left:45%;
            position: relative;

        }
    
        .d1 {
            width: 180px;
            height: 300px;
            position: absolute;
            background:url(./img/charector.png) 0 0 no-repeat;
            animation-name: move;
            animation-duration: 950ms;
            animation-iteration-count: infinite;
            /* step-start 马上跳转到动画每一帧结束的位置 */
            animation-timing-function: step-start;
        }

        @keyframes move {
            0% {
                background-position: 0 0;
            }
            14% {
                background-position: -180px 0;
            }

            28% {
                background-position: -360px 0;
            }
            42% {
                background-position: -540px 0;
            }

            56% {
                background-position: -720px 0;
            }
            70% {
                background-position: -900px 0;
            }
            84% {
                background-position: -1080px 0;
            }
            100% {
                background-position: 0 0;
            }
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="d1"></div>
    </div>
</body>
</html>

发布了192 篇原创文章 · 获赞 30 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/JackieDYH/article/details/104891882
今日推荐