aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/element/g/index.html
blob: d75c11cc71a80c4847bbc2fdc1d55c0c657b85c4 (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
100
101
102
103
104
105
106
107
---
title: g
slug: Web/SVG/Element/g
tags:
  - SVG
  - SVG容器
  - 元素
  - 参考
translation_of: Web/SVG/Element/g
---
<div>{{SVGRef}}</div>

<p>元素<code>g</code>是用来组合对象的容器。添加到<code>g</code>元素上的变换会应用到其所有的子元素上。添加到<code>g</code>元素的属性会被其所有的子元素继承。此外,<code>g</code>元素也可以用来定义复杂的对象,之后可以通过{{SVGElement("use")}}元素来引用它们。</p>

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

<p>{{svginfo}}</p>

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

<pre class="brush: html" style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none;">&lt;svg width="100%" height="100%" viewBox="0 0 95 50"
     xmlns="http://www.w3.org/2000/svg"&gt;
  &lt;g stroke="green" fill="white" stroke-width="5"&gt;
    &lt;circle cx="25" cy="25" r="15" /&gt;
    &lt;circle cx="40" cy="25" r="15" /&gt;
    &lt;circle cx="55" cy="25" r="15" /&gt;
    &lt;circle cx="70" cy="25" r="15" /&gt;
  &lt;/g&gt;
&lt;/svg&gt;
</pre>

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

<h2 id="属性">属性</h2>

<h3 id="全局属性">全局属性</h3>

<ul>
 <li><a href="/en-US/docs/SVG/Attribute#ConditionalProccessing" title="SVG/Attribute#ConditionalProccessing">条件处理属性</a> »</li>
 <li><a href="/en-US/docs/SVG/Attribute#Core" title="SVG/Attribute#Core">核心属性</a> »</li>
 <li><a href="/en-US/docs/SVG/Attribute#GraphicalEvent" title="SVG/Attribute#GraphicalEvent">图形事件属性</a> »</li>
 <li><a href="/en-US/docs/SVG/Attribute#Presentation" title="SVG/Attribute#Presentation">外观属性</a> »</li>
 <li>{{SVGAttr("class")}}</li>
 <li>{{SVGAttr("style")}}</li>
 <li>{{SVGAttr("externalResourcesRequired")}}</li>
 <li>{{SVGAttr("transform")}}</li>
</ul>

<h3 id="专有属性">专有属性</h3>

<p><em>没有专有属性。</em></p>

<h2 id="DOM接口">DOM接口</h2>

<p>该元素实现了<code><a href="/en-US/docs/DOM/SVGGElement" title="DOM/SVGGElement">SVGGElement</a>的所有接口</code>.</p>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th scope="col">Feature</th>
   <th scope="col">Chrome</th>
   <th scope="col">Firefox (Gecko)</th>
   <th scope="col">Internet Explorer</th>
   <th scope="col">Opera</th>
   <th scope="col">Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>1.0</td>
   <td>{{CompatGeckoDesktop('1.8')}}</td>
   <td>{{CompatIE('9.0')}}</td>
   <td>{{CompatOpera('8.0')}}</td>
   <td>{{CompatSafari('3.0.4')}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatAndroid('3.0')}}</td>
   <td>{{CompatGeckoMobile('1.8')}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatSafari('3.0.4')}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>该表格基于<a href="/en-US/docs/SVG/Compatibility_sources" title="SVG/Compatibility sources">这些资源</a></p>