欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CSS3中,loading加载动画

程序员文章站 2022-03-18 19:44:47
...

CSS3中,loading加载动画

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>loading-加载动画</title>
    <style type="text/css">
        .box{
            width: 300px;
            height: 130px;
            border: 1px solid #000;
            margin: 200px auto 0;
        }

        .box p{
            text-align: center;
            width: 100%;
            float: left;
            margin: 0;
            padding: 0;
        }

        .box div{
            width: 30px;
            height: 70px;
            float: left;;
            background-color: gold;
            margin:15px;
            border-radius: 12%;
        }

        .box div:nth-child(1){
            background-color: #cecece;
            animation: loading 500ms ease 0s  infinite alternate;
        }

        .box div:nth-child(2){
            background-color: pink;
            animation: loading 500ms ease 100ms  infinite alternate;
        }

        .box div:nth-child(3){
            background-color: orange;
            animation: loading 500ms ease 200ms  infinite alternate;
        }

        .box div:nth-child(4){
            background-color: red;
            animation: loading 500ms ease 300ms  infinite alternate;
        }

        .box div:nth-child(5){
            background-color: green;
            animation: loading 500ms ease 400ms  infinite alternate;
        }

        @keyframes loading{
            from{
                transform: scaleY(1.2);
            }

            to{
                transform: scaleY(0.2);
            }
        }

    </style>
</head>
<body>
    <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <p> Loading...</p>
    </div>
</body>
</html>
  • 结果如下:
    CSS3中,loading加载动画
相关标签: css3 动画