当前位置 : 主页 > 网页制作 > css >

CSS3 循环动画

来源:互联网 收集:自由互联 发布时间:2021-06-13
!DOCTYPE htmlhtml lang="en"head meta charset="UTF-8" titleDocument/title style type="text/css" * { margin: 0; padding: 0; } .box { width: 200px; height: 200px; position: relative; margin: 150px auto; /* perspective: 1000px; */ /* 将平面图
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 200px;
            height: 200px;
            position: relative;
            margin: 150px auto;
            /* perspective: 1000px; */
            /* 将平面图形转换为立体图形 */
            transform-style: preserve-3d;
            /* transform: rotateY(20deg) rotateX(150deg); */
                        /* 动画名称 动画时长 延时时间 匀速 无限循环  逆播 */ 
            animation: changes 2s 0.2s linear infinite alternate;
        }
        .box:hover {
            animation-play-state: paused;/*鼠标放上去 暂停动画 */
        }
        @keyframes changes {
            from {
                transform: translateX(0)
            }
            to {
                transform: translateX(300px)
            }
        }
    </style>
</head>

<body>

    <div class="box">
        <div class="public one1"></div>
        <div class="public one2"></div>
        <div class="public one3"></div>
        <div class="public one4"></div>
        <div class="public one5"></div>
        <div class="public one6"></div>
    </div>

</body>

</html>
网友评论