blob: 31d4a5af4304bcad1b1a174810382929cc7fc887 (
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
|
---
title: width
slug: Web/SVG/Attribute/width
tags:
- SVG
- SVG属性
- 需要兼容性表
translation_of: Web/SVG/Attribute/width
---
<p>« <a href="/en/SVG/Attribute" title="en/SVG/Attribute">SVG属性参考主页</a></p>
<p>该属性在用户坐标系统中标识了一个水平长度。该坐标的确切效果依赖于每个元素。大多数时候,它体现引用元素的矩形区域的宽度(请阅读每个元素的文档以了解例外情况)。</p>
<p>除了<code><svg></code>元素之外,别的元素都必须指定该属性,<code><svg></code>的宽度默认是<strong>100%</strong>,而<code><filter></code>元素以及<code><mask></code>元素的默认宽度是<strong>120%</strong>。</p>
<h2 id="用法">用法</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="row">类别</th>
<td>无</td>
</tr>
<tr>
<th scope="row">值</th>
<td><a href="/en/SVG/Content_type#Length" title="https://developer.mozilla.org/en/SVG/Content_type#Length"><length></a></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/extend.html#ForeignObjectElementWidthAttribute">SVG 1.1 (2nd Edition): foreignObject element</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/struct.html#ImageElementWidthAttribute">SVG 1.1 (2nd Edition): image element</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/pservers.html#PatternElementWidthAttribute">SVG 1.1 (2nd Edition): pattern element</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/shapes.html#RectElementWidthAttribute">SVG 1.1 (2nd Edition): rect element</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute">SVG 1.1 (2nd Edition): svg element</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/struct.html#UseElementWidthAttribute">SVG 1.1 (2nd Edition): use element</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/filters.html#FilterPrimitiveWidthAttribute">SVG 1.1 (2nd Edition): Filter primitive</a><br>
<a class="external" href="http://www.w3.org/TR/SVG/masking.html#MaskElementWidthAttribute">SVG 1.1 (2nd Edition): mask element</a></td>
</tr>
</tbody>
</table>
<p>{{ page("/zh-CN/docs/Web/SVG/Content_type","长度") }}</p>
<h2 id="元素">元素</h2>
<p>下列元素可以使用<code>width</code>属性:</p>
<ul>
<li><a href="/en/SVG/Element#FilterPrimitive" title="en/SVG/Element#FilterPrimitive">滤镜元素</a> »</li>
<li>{{ SVGElement("filter") }}</li>
<li>{{ SVGElement("foreignObject") }}</li>
<li>{{ SVGElement("image") }}</li>
<li>{{ SVGElement("pattern") }}</li>
<li>{{ SVGElement("rect") }}</li>
<li>{{ SVGElement("svg") }}</li>
<li>{{ SVGElement("use") }}</li>
<li>{{ SVGElement("mask") }}</li>
</ul>
|