制作CSS动画

<!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>
    <style>
        body {
            padding: 0;
            margin: 0;
            background: url(./west/bg.jpg);
            padding-top: 360px;
            animation: bj 20s linear infinite;
        }

        .background {
            width: 780px;
            background-repeat: no-repeat;
            position: absolute;
            top: 340px;
            left: 340px;
            /* margin: 0 auto;
            display: flex;
            justify-content: center; */
        }

        @keyframes bj {
            from {
                background-position: 0 0;
            }

            to {
                background-position: 1920px 0;
            }
        }

        .background div {
            overflow: hidden;
            float: left;
        }

        .background div:nth-child(1) {
            width: 200px;
        }

        .background div:nth-child(1) img {
            width: 1600px;
            animation: wkbj 2s infinite steps(8);
        }

        .background div:nth-child(2) {
            width: 200px;
        }

        .background div:nth-child(2) img {
            width: 1600px;
            animation: wkbj 3s infinite steps(8);
        }

        .background div:nth-child(3) {
            width: 170px;
        }

        .background div:nth-child(3) img {
            width: 1360px;
            animation: ts 4s infinite steps(8);
        }

        .background div:nth-child(4) {
            width: 210px;
        }

        .background div:nth-child(4) img {
            width: 1680px;
            animation: ss 3s infinite steps(8);
        }

        @keyframes wkbj {
            from {
                margin-left: 0;
            }

            to {
                margin-left: -1600px;
            }
        }

        @keyframes ts {
            from {
                margin-left: 0;
            }

            to {
                margin-left: -1360px;
            }
        }

        @keyframes ss {
            from {
                margin-left: 0;
            }

            to {
                margin-left: -1680px;
            }
        }
    </style>
</head>

<body>
    <section class="background">
        <div><img src="./west/wk.png" alt=""></div>
        <div><img src="./west/bj.png" alt=""></div>
        <div><img src="./west/ts.png" alt=""></div>
        <div><img src="./west/ss.png" alt=""></div>
    </section>
</body>

</html>
<!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>
    <style>
        div {
            box-sizing: border-box;
        }

        .room {
            width: 400px;
            height: 400px;
            background-color: black;
            margin: 0 auto;
            padding: 50px;
        }

        .outer {
            height: 100%;
            width: 100%;
            border: 3px solid #777;
            border-radius: 50%;
            padding: 20px;
        }

        .inner {
            height: 100%;
            width: 100%;
            border-radius: 50%;
            border: 10px solid #FFF;
        }

        @keyframes small {
            from {
                padding: 50px;
            }

            to {
                padding: 40px;
            }
        }

        @keyframes big {
            0% {
                padding: 20px;
            }

            100% {
                padding: 32px;
            }
        }

        .room {
            animation-name: small;
            animation-duration: 2000ms;
            animation-iteration-count: infinite;
            animation-timing-function: linear;
            animation-direction: alternate;
        }

        .outer {
            animation: big 2000ms infinite linear alternate;
        }

        body div:hover {
            animation-play-state: paused;
        }
    </style>
    </head>

    <body>
        <div class="room">
            <div class="outer">
                <div class="inner"></div>
            </div>
        </div>
    </body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值