gpt4 book ai didi

css - 如何在纯 CSS 中创建带有位于圆心的文本的圆形动画?

转载 作者:太空宇宙 更新时间:2023-11-04 09:11:23 25 4
gpt4 key购买 nike

我是 CSS 的初学者,疯狂地想弄清楚如何创建以下内容:

enter image description here

圆圈代表 100%,绿色填充代表 62%。这甚至可能只用 CSS 还是需要一些 javascript 来创建?

最佳答案

这是 progressbar.js 的例子

// progressbar.js@1.0.0 version is used
// Docs: http://progressbarjs.readthedocs.org/en/1.0.0/

var bar = new ProgressBar.Circle(container, {
color: '#7ed321',
// This has to be the same size as the maximum width to
// prevent clipping
strokeWidth: 5,
trailWidth: 5,
trailColor: '#73787d',
easing: 'easeInOut',
duration: 1400,
text: {
autoStyleContainer: false
},
from: { color: '#7ed321', width: 5 },
to: { color: '#7ed321', width: 5 },
// Set default step function for all animate calls
step: function(state, circle) {
circle.path.setAttribute('stroke', state.color);
circle.path.setAttribute('stroke-width', state.width);

var value = Math.round(circle.value() * 100);
if (value === 0) {
circle.setText('');
} else {
circle.setText(value+'%');
}

}
});
bar.text.style.fontFamily = '"Raleway", Helvetica, sans-serif';
bar.text.style.fontSize = '3rem';

bar.animate(62*0.01); // Number from 0.0 to 1.0 //currently set to 62%
#container {
width: 200px;
height: 200px;
position: relative;
background: #454b52;
padding: 20px;
}
<link href="https://fonts.googleapis.com/css?family=Raleway:400,300,600,800,900" rel="stylesheet" type="text/css">
<script src="https://rawgit.com/kimmobrunfeldt/progressbar.js/1.0.0/dist/progressbar.js"></script>
<div id="container"></div>

关于css - 如何在纯 CSS 中创建带有位于圆心的文本的圆形动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42096222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com