原创

css实现loading效果

1、效果预览

loading效果预览

2、示例代码

<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>js实现loadding</title>

<style type="text/css">

.loading1,.loading3 {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    background-color: transparent;
    z-index: 2147483647
}

.loadEffect {
    position: fixed;
    width: 200px;
    height: 200px;
    margin: 0 auto;
    margin-top: 100px;
    position: relative;
    top: 50%;
    margin-top: -100px
}

.loadEffect div {
    width: 100%;
    height: 100%;
    position: absolute;
    -webkit-animation: load 2.08s linear infinite
}

.loadEffect div .bg-danger {
    background-color: #f43438
}

.loadEffect div .bg-default {
    background-color: #00bfff
}

.loadEffect div .bg-info {
    background-color: #228b22
}

.loadEffect div .bg-success {
    background-color: #adff2f
}

.loadEffect div .bg-warning {
    background-color: #bc8f8f
}

.loadEffect div span {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px
}

@-webkit-keyframes load {
    0% {
        -webkit-transform: rotate(0deg)
    }

    10% {
        -webkit-transform: rotate(45deg)
    }

    50% {
        opacity: 1;
        -webkit-transform: rotate(160deg)
    }

    62% {
        opacity: 0
    }

    65% {
        opacity: 0;
        -webkit-transform: rotate(200deg)
    }

    90% {
        -webkit-transform: rotate(340deg)
    }

    100% {
        -webkit-transform: rotate(360deg)
    }
}

.loadEffect div:nth-child(1) {
    -webkit-animation-delay: 0s
}

.loadEffect div:nth-child(2) {
    -webkit-animation-delay: .2s
}

.loadEffect div:nth-child(3) {
    -webkit-animation-delay: .4s
}

.loadEffect div:nth-child(4) {
    -webkit-animation-delay: .6s
}

.loadEffect div:nth-child(5) {
    -webkit-animation-delay: .8s
}

.loadEffect div:nth-child(6) {
    -webkit-animation-delay: 1s
}

.loading2 {
    position: fixed;
    background-image: linear-gradient(0deg,rgba(57,94,203,0) 0%,rgba(54,87,190,.3) 35%,rgba(36,33,97,.3) 75%,rgba(26,5,49,0) 100%);
    left: 0;
    display: none;
    right: 0;
    bottom: 0;
    right: 0;
    top: 0;
    z-index: 2147483647
}

      </style>
        <head>
<body>
<div class="loading1 animated fadeIn" style="display: block;">
        <div class="loadEffect">
                    <div>
                        <span class="bg-success"></span>
                    </div>
                    <div>
                        <span class="bg-info"></span>
                    </div>
                    <div>
                        <span class="bg-warning"></span>
                    </div>
                    <div>
                        <span class="bg-danger"></span>
                    </div>
                    <div>
                        <span class="bg-default"></span>
                    </div>
                    <div>
                        <span class="bg-success"></span>
                    </div>
                    <div>
                        <span class="bg-info"></span>
                    </div>
        </div>
    </div>
</body>
</html>
正文到此结束
本文目录