纯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));
  }
}
相关推荐
aiwery3 分钟前
大模型场景下的推送技术选型:轮询 vs WebSocket vs SSE
前端·agent
会豪5 分钟前
前端插件-不固定高度的DIV如何增加transition
前端
却尘5 分钟前
Server Actions 深度剖析(2):缓存管理与重新验证,如何用一行代码干掉整个客户端状态层
前端·客户端·next.js
小菜全5 分钟前
Vue 3 + TypeScript 事件触发与数据绑定方法
前端·javascript·vue.js
Hilaku8 分钟前
面试官开始问我AI了,前端的危机真的来了吗?
前端·javascript·面试
shellvon1 小时前
前端攻防:揭秘 Chrome DevTools 与反调试的博弈
前端·逆向
β添砖java1 小时前
案例二:登高千古第一绝句
前端·javascript·css
却尘1 小时前
Server Actions 深度剖析:这就是个披着 React 外衣的 RPC
前端·rpc·next.js
南雨北斗1 小时前
Vue 3 修饰符(Modifiers)
前端
会豪1 小时前
工业仿真(simulation)--前端(七)--消息栏
前端