stroke-dasharray - SVG: Scalable Vector Graphics 编辑
The stroke-dasharray
attribute is a presentation attribute defining the pattern of dashes and gaps used to paint the outline of the shape;
Note: As a presentation attribute, stroke-dasharray
can be used as a CSS property.
As a presentation attribute, it can be applied to any element, but it only has effect on the following twelve elements:
html,body,svg { height:100% }
<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
<!-- No dashes nor gaps -->
<line x1="0" y1="1" x2="30" y2="1" stroke="black" />
<!-- Dashes and gaps of the same size -->
<line x1="0" y1="3" x2="30" y2="3" stroke="black"
stroke-dasharray="4" />
<!-- Dashes and gaps of different sizes -->
<line x1="0" y1="5" x2="30" y2="5" stroke="black"
stroke-dasharray="4 1" />
<!-- Dashes and gaps of various sizes with an odd number of values -->
<line x1="0" y1="7" x2="30" y2="7" stroke="black"
stroke-dasharray="4 1 2" />
<!-- Dashes and gaps of various sizes with an even number of values -->
<line x1="0" y1="9" x2="30" y2="9" stroke="black"
stroke-dasharray="4 1 2 3" />
</svg>
Usage notes
Value | none | <dasharray> |
---|---|
Default value | none |
Animatable | Yes |
- <dasharray>
A list of comma and/or white space separated <length>s and <percentage>s that specify the lengths of alternating dashes and gaps.
If an odd number of values is provided, then the list of values is repeated to yield an even number of values. Thus,
5,3,2
is equivalent to5,3,2,5,3,2
.
Browser compatibility
BCD tables only load in the browser
Specifications
Specification | Status | Comment |
---|---|---|
Scalable Vector Graphics (SVG) 2 The definition of 'stroke-dasharray' in that specification. | Candidate Recommendation | Definition for shapes and texts |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of 'stroke-dasharray' in that specification. | Recommendation | Initial definition for shapes and texts |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论