SVG参考手册
分类 | Elements
g
<g>
SVG元素是用于组其他SVG元素的容器。应用于<g>
元素的转换将在其所有子元素上执行,并且其任何属性都由其子元素继承。它也可以将多个元素分组,以便随后引用<use>
元素。
用法上下文
分类 |
容器元素,结构元素 |
---|---|
允许的内容 |
任意数量的下列元素,以任何顺序排列:动画元素描述元素图形元素结构元素渐变元素<a>, <altGlyphDef>, <clipPath>, <color-profile>, <cursor>, <filter>, <font>, <font-face>, <foreignObject>, <image>, <marker>, <mask>, <pattern>, <script>, <style>, <switch>, <text>, <view> |
属性
全局属性
- Conditional processing attributes
- Core attributes
- Graphical event attributes
- Presentation attributes
class
style
externalResourcesRequired
transform
具体属性
None
DOM接口
这个元素实现了SVGGElement
接口。
示例
<svg viewBox="0 0 95 50"
xmlns="http://www.w3.org/2000/svg">
<g stroke="green" fill="white" stroke-width="5">
<circle cx="25" cy="25" r="15"/>
<circle cx="40" cy="25" r="15"/>
<circle cx="55" cy="25" r="15"/>
<circle cx="70" cy="25" r="15"/>
</g>
</svg>
产品规格
Specification |
Status |
Comment |
---|---|---|
Scalable Vector Graphics (SVG) 2The definition of '<g>' in that specification. |
Candidate Recommendation |
|
Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of '<g>' in that specification. |
Recommendation |
Initial definition |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox (Gecko) |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic support |
1.0 |
(Yes) |
1.5 (1.8) |
9.0 |
8.0 |
3.0.4 |
Feature |
Android |
Edge |
Firefox Mobile (Gecko) |
IE Phone |
Opera Mobile |
Safari Mobile |
---|---|---|---|---|---|---|
Basic support |
3.0 |
(Yes) |
1.0 (1.8) |
No support |
(Yes) |
3.0.4 |