blob: 25610abd4eef6cdbd8a7895e9f855434200b9952 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
---
title: id
slug: Web/SVG/Attribute/id
translation_of: Web/SVG/Attribute/id
---
<div>{{SVGRef}}</div>
<p><strong><code>id</code></strong> 属性给予元素一个唯一名称。</p>
<p>所有元素均可使用该属性。</p>
<div id="topExample">
<pre class="brush: html"><svg width="120" height="120" viewPort="0 0 120 120" xmlns="http://www.w3.org/2000/svg">
<style type="text/css">
<![CDATA[
#smallRect {
stroke: #000066;
fill: #00cc00;
}
]]>
</style>
<rect id="smallRect" x="10" y="10" width="100" height="100" />
</svg>
</pre>
<p>{{EmbedLiveSample("topExample", "120", "120")}}</p>
</div>
<h2 id="用法说明">用法说明</h2>
<table class="properties">
<tbody>
<tr>
<th scope="row">值</th>
<td><id></td>
</tr>
<tr>
<th scope="row">默认值</th>
<td><em>None</em></td>
</tr>
<tr>
<th scope="row">可动画</th>
<td>No</td>
</tr>
</tbody>
</table>
<dl>
<dt><id></dt>
<dd>
<p>指定元素的ID。 该ID在节点树中必须是唯一的,不能为空字符串,并且不能包含任何空格字符。</p>
<div class="blockIndicator note">
<p><strong>注意:</strong> 应当避免使用会被解析为SVG视图规范的 <code>id</code> 值(如<code>MyDrawing.svg#svgView(viewBox(0,200,1000,1000))</code>),或被解析为用作URL目标片段的基本媒体片段的 <code>id</code> 值。</p>
</div>
<p>该属性取值必须在XML文档中有效。 独立的SVG文档使用XML 1.0语法,该语法指定有效的ID仅包含指定的字符(字母,数字和一些标点符号),开头不能是数字,点(.)字符或 连字符减号(-)。</p>
</dd>
</dl>
<h2 id="规范">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName("SVG2", "struct.html#IDAttribute", "id")}}</td>
<td>{{Spec2("SVG2")}}</td>
<td>Defines the allowed values in more detail.</td>
</tr>
<tr>
<td>{{SpecName("SVG1.1", "struct.html#IDAttribute", "id")}}</td>
<td>{{Spec2("SVG1.1")}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("svg.attributes.style.class")}}</p>
<h2 id="参考">参考</h2>
<ul>
<li><a href="/en-US/docs/Web/HTML/Global_attributes/id">HTML <code>id</code></a></li>
<li>{{SVGAttr("class")}}</li>
</ul>
|