css3 loading效果3

发布时间 2023-07-19 02:20:25作者: 码农-编程小子
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    :root {
        --t: 1s;
    }

    body {
        display: flex;
        justify-content: center;
        align-items: center;
        align-content: center;
        height: 100vh;
        margin: 0;
        flex-direction: column;

    }

    .loading {
        width: 200px;
        height: 200px;
        display: flex;
        align-items: center;
        justify-items: center;
        animation: animateBackground 10s linear infinite;
    }

    .loading div {
        width: 20px;
        height: 120px;
        background-color: lightgreen;
        margin-left: 10px;
        animation: load var(--t) ease infinite calc(var(--t) / 5 * var(--i));
    }

    @keyframes load {

        0%,
        100% {
            height: 120px;
            background-color: lightblue;
        }

        50% {
            height: 50px;
            background-color: lightgreen;
        }
    }
</style>

<body>

    <div class="loading">
        <div style="--i:0"></div>
        <div style="--i:1"></div>
        <div style="--i:2"></div>
        <div style="--i:3"></div>
        <div style="--i:4"></div>

    </div>

</body>

</html>