我正在使用虛線偏移動畫技術製作一個簡單的微調框。你可以看到我有什麼here。正如你所看到的,多邊形的形狀從不關閉。是否有任何簡單的方法可以確保路徑完成形狀,而不是將頂部的斜角切掉。動畫筆畫dashoffset無法關閉形狀
我可以在拍攝的路徑詮釋他的SVG,使其重疊來完成這最後一個彎道。不幸的是,你可以看到它在不理想的動畫中透支。
HTML
<div class="logo-container">
<svg class="is2-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 243.514 195.632">
<path class="gray-path" fill="none" stroke="#9A9A9A" stroke-width="16" stroke-miterlimit="10" d="M121.71 64.26l106.08 61.04-106.08 61.033L15.724 125.3z"/>
<path class="blue-path" fill="none" stroke="#00B3E9" stroke-width="16" stroke-miterlimit="10" d="M121.71 9.225l106.08 61.04-106.08 61.032L15.724 70.265z"/>
</svg>
</div>
CSS
.logo-container {
width: 400px;
.is2-logo path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
}
.blue-path {
animation: dash 2s linear forwards infinite;
}
.gray-path {
animation: dash 2s linear forwards infinite .5s;
}
}
@keyframes dash {
0% {
stroke-dashoffset: 1000;
}
50% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: -1000;
}
}
創建其他兩個路徑是除了一段短暫的時間段之外,當你想要關閉路徑時,它們是不可見的。 –
這是我的後備計劃,但它增加了複雜性,並重復了一些努力。它也會導致問題,例如,如果我希望這放在圖像或彩色背景上。我希望可能有更優雅的解決方案。 –