学习 CSS 新的属性 conic-gradient 实现环形进度条

我们在工作中用到环形进度条的时候,一般都是使用组件库提供的,那么你有没有想过这是怎么实现的呢?

html 复制代码
    <div
      class="progress"
      style="--progress: 80%; --last: 20%"
      data-progress="80%"
    ></div>

<style scoped lang="scss">
.progress {
  display: inline-block;
  margin: 50px 20px;
  width: 200px;
  height: 200px;
  background: conic-gradient(green var(--progress), #f1f1f1 var(--last));
  border-radius: 50%;
  position: relative;
  &::before {
    content: attr(data-progress);
    position: absolute;
    inset: 10px;
    background-color: #fff;
    width: 180px;
    height: 180px;
    text-align: center;
    line-height: 180px;
    border-radius: 50%;
  }
}
</style>
相关推荐
im_AMBER8 分钟前
Leetcode 67 长度为 K 子数组中的最大和 | 可获得的最大点数
数据结构·笔记·学习·算法·leetcode
Slaughter信仰18 分钟前
图解大模型_生成式AI原理与实战学习笔记(第四章)
人工智能·笔记·学习
martian66530 分钟前
详解高阶数学领域-信息论与深度学习:互信息在对比学习中的应用
人工智能·深度学习·学习
Wiktok1 小时前
TailwindCSS学习路径方法总结
学习·css3·tailwindcss
FFF团团员9091 小时前
树莓派学习笔记6:摄像头的基本使用
笔记·学习
d111111111d1 小时前
在SM32F103C8T6中MCU和MPU的区别,都有什么各自的优点,缺点,都可以用来干什么。
笔记·stm32·单片机·嵌入式硬件·学习
solicitous1 小时前
QA和测试得区别
学习
盐焗西兰花2 小时前
鸿蒙学习实战之路:Dialog 组件封装最佳实践
学习·华为·harmonyos
van久2 小时前
.NET Core 学习第二天:Razor Pages 新建页面及增删改查
学习·.netcore
铅笔侠_小龙虾2 小时前
Vue 学习目录
前端·vue.js·学习