CSS3简单实现360deg旋转

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<style>
    .stage{
        width: 200px;
        height: 200px;
        background-color: #acffa5;
    }
    .box1{
        width: 50px;
        height: 50px;
        background-color: #b2caff;

        animation: rotate  2s linear infinite;
    }

    .box1:hover{
        animation-play-state: paused;
    }
    @keyframes rotate {
        0%{
            transform: rotate(0);
        }
        100%{
            transform: rotate(360deg);
        }
    }


</style>
<body>

<div class="stage">
    <div class="box1"> 1</div>
</div>

</body>
</html>
animation: name duration timing-function delay iteration-count direction fill-mode play-state;
说明
animation-name 指定要绑定到选择器的关键帧的名称
animation-duration 动画指定需要多少秒或毫秒完成
animation-timing-function 设置动画将如何完成一个周期
animation-delay 设置动画在启动前的延迟间隔。
animation-iteration-count 定义动画的播放次数。
animation-direction 指定是否应该轮流反向播放动画。
animation-fill-mode 规定当动画不播放时(当动画完成时,或当动画有一个延迟未开始播放时),要应用到元素的样式。
animation-play-state 指定动画是否正在运行或已暂停。
initial 设置属性为其默认值。 阅读关于 initial的介绍。
inherit 从父元素继承属性。 阅读关于 initinherital的介绍。

猜你喜欢

转载自blog.csdn.net/TCF_JingFeng/article/details/86665489