往复运动

本文最后更新于:6 个月前

实现往复运动,主要就是animation的四个参数,持续时间 动画 延迟时间 执行次数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="box"></div>
</body>
<style>
    #box {
        width: 100px;
        height: 100px;
        background-color: aquamarine;
        animation: 10s yun 0s infinite;
    }
    @keyframes yun{
        0%{
            transform: translate(0,0);
        }
        50%{
            transform: translate(300px,0);
        }
        100%{
            transform: translate(0,0);
        }
    }
</style>
</html>

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!