Vue/微信小程序 自定义加载中loading效果

 1、HTML代码

    <div id="loading">
      <div class="hover" id="circle">
        <div class="right load"></div>
        <div class="left load"></div>
      </div>
      <img src="http://xcximg.luzhuoquan.com/official/loading.png" alt="加载中…" class="load-img" />
    </div>

2、CSS代码 

    #loading {
      width: 100%;
      height: 100vh;
      overflow: hidden;
      background-color: #fff;
      position: fixed;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
      z-index: 1000;
    }
    .load-img {
      width: 120px;
      height: 120px;
      position: absolute;
      left: 50%;
      top: 50%;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      z-index: 1;
    }
    #circle {
      width: 120px;
      height: 120px;
      border-width: 0;
      clip: rect(0px, 120px, 120px, 60px);
      position: absolute;
      left: 50%;
      top: 50%;
      border-radius: 50%;
      transform: translate(-50%, -50%);
    }
    .load {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      border-radius: 50%;
      border: 2px solid #008c96;
      box-sizing: border-box;
      z-index: 2;
    }
    #circle .left,
    #circle .right {
      border-right-color: rgba(0, 0, 0, 0);
      border-bottom-color: rgba(0, 0, 0, 0);
      transform: rotate(-45deg);
    }

    #circle .left {
      border-left: 2px solid #008c96;
      border-top: 2px solid #008c96;
      animation: left-animation 1s linear;
    }

    @keyframes left-animation {
      0% {
        transform: rotate(-45deg);
      }
      50% {
        transform: rotate(135deg);
      }
      100% {
        transform: rotate(315deg);
      }
    }

    #circle .right {
      border-left: 2px solid #008c96;
      border-top: 2px solid #008c96;
      animation: right-animation 1s linear;
    }

    @keyframes right-animation {
      0% {
        transform: rotate(-45deg);
      }
      50% {
        transform: rotate(135deg);
      }
      100% {
        transform: rotate(135deg);
      }
    }

    #circle.hover {
      animation: circle-animation 1s linear;
    }

    @keyframes circle-animation {
      0% {
        clip: rect(0px, 200px, 200px, 100px);
      }
      100% {
        clip: auto;
      }
    }

3、效果图:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值