纯css实现环形进度条

需要在中实现一个定制化的环形进度条,最终效果如图:

使用代码

html 复制代码
 <div
                    class="circular-progress"
                    :style="{
                      '--progress': nextProgress,
                      '--color': endSliderColor,
                      '--size': isFull ? '60rpx' : '90rpx',
                    }"
                  >
                    <div class="inner-content">
                      <img
                        :class="isFull ? 'next_btn_full' : 'next_btn_normal'"
                         :src="`${assetsHost}dsplayer/next.png`"
                        alt=""
                      />
                    </div>
                  </div>

css代码:

css 复制代码
/* 内层遮罩实现环形效果 */
.circular-progress::before {
  content: "";
  position: absolute;
  width: 80%;
  height: 80%;
  background: rgba(0, 0, 0, 1);
  border-radius: 50%;
}

.inner-content {
  position: relative;
  z-index: 1;
  font-size: 1.2em;
  color: var(--color);
}

/* 兼容方案(可选) */
@supports not (background: conic-gradient(#000, #fff)) {
  .circular-progress {
    background: var(--bg-color);
  }

  .circular-progress::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    clip: rect(0, var(--size), var(--size), calc(var(--size) / 2));
    background: var(--color);
    transform: rotate(calc(var(--progress) * 3.6deg));
  }
}
相关推荐
独立开阀者_FwtCoder2 分钟前
基于 MCP Http SSE模式的天气助手智能体开发实战(一文带你了解MCP两种开发模式)
前端·javascript·后端
月亮慢慢圆14 分钟前
表格单元行合并方法
前端
方阿森15 分钟前
MasterGo + MCP,借助 AI 实现设计稿转代码
前端·ai编程·mcp
逆袭的小黄鸭16 分钟前
一文读懂 JavaScript 的各类继承方式
前端·javascript·面试
谎言西西里18 分钟前
深入浅出 Pinia:革新 Vue 状态管理的利器 ⚡
前端
loooseFish18 分钟前
带分页的docx编辑器 vue3集成canvas-editor
前端
敲代码的玉米C19 分钟前
深入探讨 JavaScript 中的 setTimeout 精确性问题
前端·javascript
XH27620 分钟前
Kotlin infix函数用法详解
前端·kotlin
独立开阀者_FwtCoder20 分钟前
V4 版本发布!强势兼容 Vue、React!
前端·javascript·后端
申小兮23 分钟前
Vue Router
前端·vue.js·vue-router