aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/attribute/stroke-dasharray/index.html
blob: 9ecc44d9dcf827c1a0d4a776b3efa7c29db40c16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
title: stroke-dasharray
slug: Web/SVG/Attribute/stroke-dasharray
tags:
  - SVG
  - SVG属性
  - 需要兼容性表
translation_of: Web/SVG/Attribute/stroke-dasharray
---
<p>« <a href="/en/SVG/Attribute" title="en/SVG/Attribute">SVG属性参考主页</a></p>

<p><code><font face="Open Sans, Arial, sans-serif">属性</font>stroke-dasharray可</code>控制用来描边的点划线的图案范式。</p>

<p>作为一个外观属性,它也可以直接用作一个CSS样式表内部的属性。</p>

<h2 id="用法">用法</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="row">类别</th>
   <td>外观属性</td>
  </tr>
  <tr>
   <th scope="row"></th>
   <td><strong title="this is the default value">none</strong> | &lt;dasharray&gt; | inherit</td>
  </tr>
  <tr>
   <th scope="row">可变性</th>
   <td>Yes</td>
  </tr>
  <tr>
   <th scope="row">规范文档</th>
   <td><a class="external" href="http://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty" title="http://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty">SVG 1.1 (2nd Edition)</a></td>
  </tr>
 </tbody>
</table>

<dl>
 <dt>&lt;dasharray&gt;</dt>
 <dd>它是一个<span><a href="/en/SVG/Content_type#Length" title="en/SVG/Content_type#Length">&lt;length&gt;</a></span><a href="/en/SVG/Content_type#Percentage" title="en/SVG/Content_type#Percentage">&lt;percentage&gt;</a>数列,数与数之间用逗号或者空白隔开,指定短划线和缺口的长度。如果提供了奇数个值,则这个值的数列重复一次,从而变成偶数个值。因此,<strong>5,3,2</strong>等同于<strong>5,3,2,5,3,2</strong></dd>
</dl>

<h2 id="示例">示例</h2>

<pre class="brush: html">&lt;?xml version="1.0"?&gt;
&lt;svg width="200" height="200" viewPort="0 0 200 300" version="1.1" xmlns="http://www.w3.org/2000/svg"&gt;

    &lt;line stroke-dasharray="5, 5"              x1="10" y1="10" x2="190" y2="10" /&gt;
    &lt;line stroke-dasharray="5, 10"             x1="10" y1="30" x2="190" y2="30" /&gt;
    &lt;line stroke-dasharray="10, 5"             x1="10" y1="50" x2="190" y2="50" /&gt;
    &lt;line stroke-dasharray="5, 1"              x1="10" y1="70" x2="190" y2="70" /&gt;
    &lt;line stroke-dasharray="1, 5"              x1="10" y1="90" x2="190" y2="90" /&gt;
    &lt;line stroke-dasharray="0.9"               x1="10" y1="110" x2="190" y2="110" /&gt;
    &lt;line stroke-dasharray="15, 10, 5"         x1="10" y1="130" x2="190" y2="130" /&gt;
    &lt;line stroke-dasharray="15, 10, 5, 10"     x1="10" y1="150" x2="190" y2="150" /&gt;
    &lt;line stroke-dasharray="15, 10, 5, 10, 15" x1="10" y1="170" x2="190" y2="170" /&gt;
    &lt;line stroke-dasharray="5, 5, 1, 5"        x1="10" y1="190" x2="190" y2="190" /&gt;

&lt;style&gt;&lt;![CDATA[
line{
    stroke: black;
    stroke-width: 2;
}
]]&gt;&lt;/style&gt;
&lt;/svg&gt;</pre>

<p><strong>示例输出</strong></p>

<p>{{ EmbedLiveSample('Example','220','220') }}</p>

<h2 id="元素">元素</h2>

<p>下列元素可以使用<code>stroke-dasharray属性:</code></p>

<ul>
 <li><a href="/en/SVG/Element#Shape_elements" title="en/SVG/Element#Shape_elements">形状元素</a> »</li>
 <li><a href="/en/SVG/Element#Text_content_elements" title="en/SVG/Element#Text_content_elements">文本内容元素</a> »</li>
</ul>