Siparat Asked:2022-07-10 16:35:27 +0800 CST2022-07-10 16:35:27 +0800 CST 2022-07-10 16:35:27 +0800 CST 复杂元素的布局 772 请告诉我如何制作这个元素(即一个圆圈)。它是动态的 html 1 个回答 Voted Best Answer Проста Miha 2022-07-10T17:33:47+08:002022-07-10T17:33:47+08:00 像这样,希望对你有帮助 .circle { --p: 20; width: 200px; aspect-ratio: 1; position: relative; display: flex; justify-content: center; align-items: center; z-index: 999; font-size: 25px; font-weight: bold; font-family: consolas; } .circle:before { content: ""; position: absolute; border-radius: 50%; inset: 0; z-index: -1; background: conic-gradient(green calc(var(--p)*1%), #0000 0); -webkit-mask: radial-gradient(farthest-side, #0000 calc(99% - 20px), #000 calc(100% - 20px)); mask: radial-gradient(farthest-side, #0000 calc(99% - 20px), #000 calc(100% - 20px)); } <div class="circle" style="--p:30"> 30%</div>
像这样,希望对你有帮助