纯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));
  }
}
相关推荐
光影少年7 分钟前
前端如何虚拟列表优化?
前端·react native·react.js
Moment9 分钟前
一杯茶时间带你基于 Yjs 和 reactflow 构建协同流程图编辑器 😍😍😍
前端·后端·面试
invicinble26 分钟前
对于前端数据的生命周期的认识
前端
PieroPc30 分钟前
用FastAPI 后端 和 HTML/CSS/JavaScript 前端写一个博客系统 例
前端·html·fastapi
名字越长技术越强32 分钟前
html\css\js(一)
javascript·css·html
hunter145036 分钟前
2026.1.4 html简单制作
java·前端·笔记·html
鹏程十八少37 分钟前
Android 深入剖析Android内存泄漏:ViewPager2与Fragment的生命周期陷阱
android·前端·app
李少兄38 分钟前
深入理解 CSS opacity 属性
前端·css
幺零九零零39 分钟前
前端测试·1
前端
1024小神41 分钟前
uniapp项目中使用vue3和小程序组件父子通信
前端·小程序·uni-app