aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/attribute/id/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/svg/attribute/id/index.html')
-rw-r--r--files/zh-cn/web/svg/attribute/id/index.html99
1 files changed, 99 insertions, 0 deletions
diff --git a/files/zh-cn/web/svg/attribute/id/index.html b/files/zh-cn/web/svg/attribute/id/index.html
new file mode 100644
index 0000000000..25610abd4e
--- /dev/null
+++ b/files/zh-cn/web/svg/attribute/id/index.html
@@ -0,0 +1,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">&lt;svg width="120" height="120" viewPort="0 0 120 120" xmlns="http://www.w3.org/2000/svg"&gt;
+ &lt;style type="text/css"&gt;
+ &lt;![CDATA[
+ #smallRect {
+ stroke: #000066;
+ fill: #00cc00;
+ }
+ ]]&gt;
+ &lt;/style&gt;
+
+ &lt;rect id="smallRect" x="10" y="10" width="100" height="100" /&gt;
+&lt;/svg&gt;
+</pre>
+
+<p>{{EmbedLiveSample("topExample", "120", "120")}}</p>
+</div>
+
+<h2 id="用法说明">用法说明</h2>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">值</th>
+ <td>&lt;id&gt;</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>&lt;id&gt;</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>