--- title: stroke-dasharray slug: Web/SVG/Attribute/stroke-dasharray tags: - SVG - SVG属性 - 需要兼容性表 translation_of: Web/SVG/Attribute/stroke-dasharray ---
属性stroke-dasharray可控制用来描边的点划线的图案范式。
作为一个外观属性,它也可以直接用作一个CSS样式表内部的属性。
| 类别 | 外观属性 |
|---|---|
| 值 | none | <dasharray> | inherit |
| 可变性 | Yes |
| 规范文档 | SVG 1.1 (2nd Edition) |
<?xml version="1.0"?>
<svg width="200" height="200" viewPort="0 0 200 300" version="1.1" xmlns="http://www.w3.org/2000/svg">
<line stroke-dasharray="5, 5" x1="10" y1="10" x2="190" y2="10" />
<line stroke-dasharray="5, 10" x1="10" y1="30" x2="190" y2="30" />
<line stroke-dasharray="10, 5" x1="10" y1="50" x2="190" y2="50" />
<line stroke-dasharray="5, 1" x1="10" y1="70" x2="190" y2="70" />
<line stroke-dasharray="1, 5" x1="10" y1="90" x2="190" y2="90" />
<line stroke-dasharray="0.9" x1="10" y1="110" x2="190" y2="110" />
<line stroke-dasharray="15, 10, 5" x1="10" y1="130" x2="190" y2="130" />
<line stroke-dasharray="15, 10, 5, 10" x1="10" y1="150" x2="190" y2="150" />
<line stroke-dasharray="15, 10, 5, 10, 15" x1="10" y1="170" x2="190" y2="170" />
<line stroke-dasharray="5, 5, 1, 5" x1="10" y1="190" x2="190" y2="190" />
<style><![CDATA[
line{
stroke: black;
stroke-width: 2;
}
]]></style>
</svg>
示例输出
{{ EmbedLiveSample('Example','220','220') }}
下列元素可以使用stroke-dasharray属性: