svg圆圈loading的实现

效果:

在这里插入图片描述

代码:

<!DOCTYPE html>
<html>
  <head>
    <meta
      name="viewport"
      content="initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"
    />
    <title></title>
    <style type="text/css">
      .loading-wrapper {
        position: absolute;
        top: 50%;
        left: 50%;
        margin-top: -21px;
        margin-left: -21px;
      }
      .circular {
        width: 42px;
        height: 42px;
        animation: loading-rotate 2s linear infinite;
      }
      .path {
        animation: loading-dash 1.5s ease-in-out infinite;
        stroke-dasharray: 90 120;
        stroke-dashoffset: 0;
        stroke-width: 2;
        stroke: #222;
        stroke-linecap: round;
      }
      @keyframes loading-dash {
        0% {
          stroke-dasharray: 1 200;
          stroke-dashoffset: 0;
        }
        50% {
          stroke-dasharray: 90 150;
          stroke-dashoffset: -40px;
        }
        100% {
          stroke-dasharray: 90 150;
          stroke-dashoffset: -120px;
        }
      }

      @keyframes loading-rotate {
        to {
          transform: rotate(1turn);
        }
      }
    </style>
  </head>
  <body>
    <div class="loading-wrapper">
      <svg viewbox="0 0 50 50" class="circular">
        <circle cx="25" cy="25" r="20" fill="none" class="path"></circle>
      </svg>
    </div>
  </body>
</html>

改变大小:

修改 circular 样式的大小,可以改变 loading 的大小。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值