CSS实现钟摆效果

效果图

在这里插入图片描述

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>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width:150px;
            height:400px;
            background: url("clock.png") no-repeat;
            margin: auto;
            /* animation : 动画的名字 时间  匀速  无限 */
            animation:move 2s linear infinite;
            transform-origin: top center;
        }
        /* @keyframes: 自定义动画 */
        @keyframes move{
            0%{
                transform: rotate(0deg);
            }
            25%{
                transform: rotate(45deg);
            }
            50%{
                transform: rotate(0deg);
            }
            75%{
                transform: rotate(-45deg);
            }
            100%{
                transform: rotate(0deg);
            }
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>

    </script>
</body>
</html>

图片资源

clock.png
在这里插入图片描述

发布了51 篇原创文章 · 获赞 13 · 访问量 3082

猜你喜欢

转载自blog.csdn.net/Sheng_zhenzhen/article/details/103944167