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

时间:2017-11-09 12:38:07

标签: html css svg

我有动画的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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您遗失的是hidden parameters个关键字。有关详情,请参阅the docs

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

@keyframes dash {
    to {
        stroke-dashoffset: 1000;
    }
}
&#13;
&#13;
&#13;