Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

SVG中stroke-dasharray的问题

http://codepen.io/anon/pen/vg...

id=yunpath 设置 stroke-dasharray=100% ,结果如上述 demo 所示

如果 100% 换成不带单位的 stroke-dasharray=707 图形位置和设置为 100% 时一样

根据 MDN https://developer.mozilla.org...

  • when a percentage length value represents a percentage of the viewport width or height

  • when a percentage length value represents a percentage of the bounding box width or height on a given object.

感觉 demo 中没有那个宽度或高度是 707 左右

请问 这个 stroke-dasharray=100% 的长度是相对哪个而言的呢?
为什么 demo 中这个 100% 又差不多等于 707 的效果呢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

stroke-dasharray=100% 是svg元素路径的总长度吧 可以用element.getTotalLength()获得


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...