如何在中风 - 戴式和中风挡群圆圈上实现动画?
我尝试使用中风线制作Piechart,但是行不通。这个想法是Piechart将是从0到50行的动画。
#circle{
stroke-dasharray: 50 100;
stroke-dashoffset: 0;
fill: none;
stroke: black;
stroke-width: 5px;
transition: 0.3s;
animation: progress 5s linear forwards;
@keyframes progress {
from {
stroke-dasharray: 0 100;
stroke-dashoffset: 0;
}
to {
stroke-dasharray: 50 100;
stroke-dashoffset: 50;
}
}
}
<svg >
<circle cx='24' cy='24' r='18' id="circle"/>
</svg>
I try to make piechart using stroke line, however isn't work. The idea is piechart will be animate from 0 to 50 line.
#circle{
stroke-dasharray: 50 100;
stroke-dashoffset: 0;
fill: none;
stroke: black;
stroke-width: 5px;
transition: 0.3s;
animation: progress 5s linear forwards;
@keyframes progress {
from {
stroke-dasharray: 0 100;
stroke-dashoffset: 0;
}
to {
stroke-dasharray: 50 100;
stroke-dashoffset: 50;
}
}
}
<svg >
<circle cx='24' cy='24' r='18' id="circle"/>
</svg>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
关键帧处于规则不是该元素的CSS选择器的一部分。默认情况下,圆的路径从3点开始。可以使用属性路径长度控制圆路径的总长度。如果动画应顺时针顺时针进行,我认为通过在圆上设置转换/旋转属性而不是使用dasharray偏移来控制起点。
The keyframes at-rule is not part of the CSS selector for the element. As default the path of the circle starts at 3 o'clock. The total length of the circle path can be controlled using the attribute pathLength. If the animation should go clockwise I think is is easier to control the starting point by setting the transform/rotate attribute on the circle instead of using the dasharray offset.