最终效果

照片

CSS3实现

  • 使用 conic-gradient 创建圆形渐变效果
  • 通过CSS变量 --progress 控制进度显示
  • 包含起点和终点的弧度标记
  • 中心有一个小圆圈作为内部填充

最终实现

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .progress {
        width: 28px;
        height: 28px;
        background: conic-gradient(
          rgba(0, 118, 255, 0.3),
          rgba(0, 118, 255, 1) var(--progress),
          #fff var(--progress)
        );
        border-radius: 50%;
        position: relative;
        animation: spin;
        animation-timing-function: linear;
        animation-duration: 1s;
        animation-iteration-count: infinite;
      }
      /* 起点的弧度 */
      .progress::before {
        position: absolute;
        top: 0;
        left: 50%;
        display: inline-block;
        content: '';
        width: 4px;
        height: 2px;
        border-radius: 4px 4px 0 0;
        background-color: rgba(0, 118, 255, 0.3);
        transform: translate(-75%, 50%) rotate(-90deg);
        z-index: 10;
      }
      .small-circle {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        background-color: #fff;
        border-radius: 50%;
      }
      .small-circle::before {
        display: inline-block;
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 24px;
        height: 24px;
        background: rgba(0, 118, 255, 1);
        transform: translate(-50%, -50%);
        opacity: 8%;
        border-radius: 50%;
        z-index: 10;
      }
      .circle-arc {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        /* 这个旋转的角度 是 360*progress(百分比 /100)    */
        /*             例子  360 * 0.7 = 252 */
        transform: rotate(262.8deg);
      }
      /* 终点的弧度 */
      .circle-arc::before {
        position: absolute;
        display: inline-block;
        content: '';
        width: 4px;
        height: 2px;
        border-radius: 4px 4px 0 0;
        background-color: rgba(0, 118, 255, 1);
        top: 0;
        left: 50%;
        transform: translate(-27%, 50%) rotate(90deg);
        z-index: 10;
      }
      @keyframes spin {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }
    </style>
  </head>
  <body>
    <div class="progress rotate" style="--progress: 73%">
      <div class="small-circle"></div>
      <div class="circle-arc"></div>
    </div>
    <script></script>
  </body>
</html>

SVG实现

  • 定义线性渐变
  • 内部背景圆
  • 外圈弧线

最终实现

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <svg width="24" height="24" viewBox="0 0 24 24">
      <!-- 渐变定义 -->
      <defs>
        <linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="0%">
          <stop offset="0%" stop-color="rgba(0, 118, 255, 0.3)" />
          <stop offset="100%" stop-color="rgba(0, 118, 255, 1)" />
        </linearGradient>
      </defs>
      <!-- 内部淡蓝色圆 -->
      <circle cx="12" cy="12" r="9" fill="rgba(0, 118, 255, 0.08)" />
      <!-- 外圈弧(单独加 class 旋转) -->
      <circle
        class="arc"
        cx="12"
        cy="12"
        r="10"
        fill="none"
        stroke="url(#grad)"
        stroke-width="3"
        stroke-linecap="round"
        stroke-dasharray="47.1"
        stroke-dashoffset="5"
      />
      <!-- stroke-dasharray = 2 * Math.PI * r * 百分比  -->
    </svg>

    <style>
      .arc {
        animation: rotate 1s linear infinite;
        transform-origin: 12px 12px;
      }
      @keyframes rotate {
        to {
          transform: rotate(360deg);
        }
      }
    </style>
  </body>
</html>