2017-09-05 53 views
1

雖然使用動畫svg工作,我發現奇怪的問題,筆畫dashoffset不適合我。我想讓自己吸引人。stroke-dashoffset does not for me

我創建了一支筆,所以你可以在這裏觀看: https://codepen.io/kalreg/pen/yorQaV

<svg> 
    <path stroke="red" fill="none" stroke-width=10 stroke-dashoffset=6530 d="M5,50 L60,105 L150,5"></path> 
</svg> 

都修改CSS或從負路徑的屬性到0至正值犯規的對號

我改變外觀不知道我在做什麼錯誤,所以任何建議都將不勝感激。 謝謝。

回答

1

stroke-dashoffset動畫以stroke-dasharray一起工作,你也缺少@keyframes實際有動畫:

path { 
    stroke-dasharray: 6630; 
    stroke-dashoffset: 6630; 
    animation: dash 5s linear forwards; 
} 

@keyframes dash { 
    to { 
    stroke-dashoffset: 0; 
    } 
} 

這裏是更新您的codepen:
https://codepen.io/anon/pen/mMgQMY

+0

的是長度路徑只有212.3。所以6630的dasharray是不必要的大。使用類似於213的東西。 https://codepen.io/anon/pen/qXGaOv –

+0

謝謝。這解決了一個問題。 – Kalreg