几个loading动画---可更新

Posted by 甘家城 on 2017-05-30 Viewed times

因为网络等因素,有时候浏览器加载页面时间会很长,一直让用户看着白屏幕也不好。

所以需要有loading动画来挽留用户。

这个动画可以用css实现,也可以用js实现。

这里先举两个简单的css的例子:

点击这里看演示

另一个演示

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>loading</title>
    <style type="text/css">
        .loading{
            position:relative;
        }
        .loading span{
            position: absolute;
            bottom:-40px;
            width: 10px;
            height: 5px;
            background-color: #000;
            -webkit-animation:loading 1s;
            -webkit-animation-iteration-count:infinite;
            animation-timing-function: linear;
        }
        .loading span:nth-child(2){
            left: 30px;
            animation-delay: .2s;
        }
        .loading span:nth-child(3){
            left: 60px;
            animation-delay: .4s;
        }
        .loading span:nth-child(4){
            left: 90px;
            animation-delay: .6s;
        }
        .loading span:nth-child(5){
            left: 120px;
            animation-delay: .8s;
        }
        @-webkit-keyframes loading
        {
            0%   {height: 5px;transform:translateY(0px);}
            50%  {height: 30px;transform:translateY(15px);}
            100% {height: 5px;transform:translateY(0px);}
        }
    </style>
</head>
<body>
    <div class="loading">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
    </div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .loading,.loadingjs{
            font-size: 50px;
        }
        .loading span{
            position: absolute;
        }
        .loading span{
            left:-10%;
            width:100px;
            animation:mymove 5s infinite;
            animation-timing-function: cubic-bezier(0.38, 0.99, 0.45, 0.13);
        }
        .loading span:nth-child(2){
            animation-delay:0.3s;
        }
        .loading span:nth-child(3){
            animation-delay:0.6s;
        }
        .loading span:nth-child(4){
            animation-delay:0.9s;
        }
        .loading span:nth-child(5){
            animation-delay:1.2s;
        }
        @keyframes mymove{
            from {left:-10%;}
            to {left: 90%;}
        }
    </style>
</head>
<body>
    <div class="loading" id="loading">
        <span>.</span>
        <span>.</span>
        <span>.</span>
        <span>.</span>
        <span>.</span>
    </div>
    </script>
</body>
</html>

版权声明:本文为原创文章,转载请注明出处和作者,不得用于商业用途,请遵守 CC BY-NC-SA 4.0协议。

支付宝打赏 微信打赏

赞赏一下