css3实现三种不同的loading加载动画效果

HTML:

<div class="box">
    <div class="loader">
        <div class="loading-1">
            <i></i>
        </div>
    </div>
    <div class="loader">
        <div class="loading-2">
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
        </div>
    </div>      
    <div class="loader">
        <div class="loading-3">
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>     
        </div>
    </div>      
</div>

CSS:

.box{
    width: 100%;
    padding: 3%;
    box-sizing: border-box;
    overflow: hidden;
}
.loader{
    width: 30%;
    border: 1px solid #ccc;
    float: left;
    margin-left: 3%;
    height: 200px;
    display: flex;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
}
/*第一种动画加载开始*/
.loading-1{
    width: 35px;
    height: 35px;
    position: relative;
}
@-webkit-keyframes loading-1{
    0%{
        transform: rotate(0deg);
    }
    50%{
        transform: rotate(180deg);
    }
    100%{
        transform: rotate(360deg);
    }
}
.loading-1 i{
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(transparent 0%,transparent 70%,#333 30%,#333 100%);
    -webkit-animation: loading-1 0.6s linear 0s infinite;
}
/*第一种动画加载结束*/

/*第二种动画加载开始*/
@-webkit-keyframes loading-2{
    0%{
        transform: scale(1);
    }
    50%{
        transform: scale(0.4);
    }
    100%{
        transform: scale(1);
    }
}
.loading-2 i{
    display: inline-block;
    width: 4px;
    height: 35px;
    margin: 0 2px;
    background: #333;
    border-radius: 2px;
    -webkit-animation: loading-2 1s ease-in 0.1s infinite;
}
.loading-2 i:nth-child(1){
    -webkit-animation: loading-2 1s ease-in 0.1s infinite;
}
.loading-2 i:nth-child(2){
    -webkit-animation: loading-2 1s ease-in 0.2s infinite;
}   
.loading-2 i:nth-child(3){
    -webkit-animation: loading-2 1s ease-in 0.3s infinite;
}   
.loading-2 i:nth-child(4){
    -webkit-animation: loading-2 1s ease-in 0.4s infinite;
}   
.loading-2 i:nth-child(5){
    -webkit-animation: loading-2 1s ease-in 0.5s infinite;
}   
/*第二种动画加载结束*/

/*第三种动画加载开始*/   
@-webkit-keyframes loading-3{
    50%{
        transform: scale(0.4);
        opacity: 0.3;
    }
    100%{
        transform: scale(1);
        opacity: 1;
    }
}
.loading-3{
    position: relative;
}
.loading-3 i{
    display: block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    position: absolute;
    background: #333;
}
.loading-3 i:nth-child(1){
    top: 25px;
    left: 0;
    -webkit-animation: loading-3 1s ease 0s infinite;
}
.loading-3 i:nth-child(2){
    top: 17px;
    left: 17px;
    -webkit-animation: loading-3 1s ease 0.12s infinite;
}
.loading-3 i:nth-child(3){
    top: 0;
    left: 25px;
    -webkit-animation: loading-3 1s ease 0.24s infinite;
}
.loading-3 i:nth-child(4){
    top: -17px;
    left: 17px;
    -webkit-animation: loading-3 1s ease 0.36s infinite;
}
.loading-3 i:nth-child(5){
    top: -25px;
    left: 0;
    -webkit-animation: loading-3 1s ease 0.48s infinite;
}
.loading-3 i:nth-child(6){
    top: -17px;
    left: -17px;
    -webkit-animation: loading-3 1s ease 0.6s infinite;
}
.loading-3 i:nth-child(7){
    top: 0;
    left: -25px;
    -webkit-animation: loading-3 1s ease 0.72s infinite;
}
.loading-3 i:nth-child(8){
    top: 17px;
    left: -17px;
    -webkit-animation: loading-3 1s ease 0.84s infinite;   
}
/*第三种动画加载结束*/

效果:
这里写图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值