gpt4 book ai didi

html - 我的 svg 在动画的某个时刻停止

转载 作者:太空宇宙 更新时间:2023-11-04 07:57:56 24 4
gpt4 key购买 nike

我有一个 SVG 元素(见下文)动画但一段时间后它停止动画。我希望动画继续像这样 jsfiddle .

.path {
stroke-dasharray: 20;
animation: dash 10s linear;
}

@keyframes dash {
to {
stroke-dashoffset: 1000;
}
}
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="340px"
height="333px" viewBox="0 0 340 333" enable-background="new 0 0 340 333"
xml:space="preserve">
<path class="path" fill="#fff" stroke="#000" stroke-width="2"
d="m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-
1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2
1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z"/>
</svg>

最佳答案

您只缺少 infinite 关键字。引用the docs了解更多。

.path {
stroke-dasharray: 20;
animation: dash 10s linear infinite;
}

@keyframes dash {
to {
stroke-dashoffset: 1000;
}
}
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="340px"
height="333px" viewBox="0 0 340 333" enable-background="new 0 0 340 333"
xml:space="preserve">
<path class="path" fill="#fff" stroke="#000" stroke-width="2"
d="m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-
1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2
1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z"/>
</svg>

关于html - 我的 svg 在动画的某个时刻停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47202086/

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