纯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));
  }
}
相关推荐
To_OC9 小时前
别再串行写 await 了,Promise.all 才是并行请求的正确打开方式
前端·javascript·promise
vipbic9 小时前
中后台越做越乱后,我用插件化把它救回来了
前端·vue.js
Hyyy9 小时前
Computer Use 适合做什么,不适合做什么——一次真实使用后的思考
前端
小和尚同志10 小时前
前端 AI 单元测试思考与落地
前端·人工智能·aigc
invicinble11 小时前
c端系统,其实更像一个信息展示平台
前端
李姆斯12 小时前
管理是否可以被完全量化
前端·产品经理·团队管理
名字还没想好☜12 小时前
Next.js 中间件实战:鉴权、重定向与 A/B 分流
开发语言·前端·javascript·中间件·react·next.js
广州灵眸科技有限公司13 小时前
瑞芯微RV1126B开发板(EASY-EAI-PI2) INI文件操作
java·前端·javascript·网络·人工智能
kaiking_g13 小时前
vue项目中,静态导入 vs 动态导入 详解
前端·javascript·vue.js
江华森13 小时前
Web 开发基础:HTTP 与 REST
前端·网络协议·http