<a>
<defs>
<g>
<marker>
<mask>
<missing-glyph>
<pattern>
<svg>
<switch>
<symbol>
<feBlend>
<feColorMatrix>
<feComponentTransfer>
<feComposite>
<feConvolveMatrix>
<feDiffuseLighting>
<feDisplacementMap>
<feDistantLight>
<feFlood>
<feFuncA>
<feFuncB>
<feFuncG>
<feFuncR>
<feGaussianBlur>
<feImage>
<feMerge>
<feMergeNode>
<feMorphology>
<feOffset>
<fePointLight>
<feSpecularLighting>
<feSpotLight>
<feTile>
<feTurbulence>
<filter>
<font>
<font-face>
<font-face-format>
<font-face-name>
<font-face-src>
<font-face-uri>
<foreignObject>
<switch>
SVG
element evaluates any
requiredFeatures
,
requiredExtensions
and
systemLanguage
attributes on its direct child elements in order, and then renders the first child where these attributes evaluate to true.
Other direct children will be bypassed and therefore not rendered. If a child element is a container element, like
<g>
, then its subtree is also processed/rendered or bypassed/not rendered.
注意:
display
and
visibility
properties have no effect on
<switch>
element processing. In particular, setting
display:none
on a child has no effect on the true/false testing for
<switch>
processing.
| 类别 | 容器元素 |
|---|---|
| 准许内容 |
Any number of the following elements, in any order:
Animation elements Descriptive elements Shape elements
<a>
,
<foreignObject>
,
<g>
,
<image>
,
<svg>
,
<switch>
,
<text>
,
<use>
|
class
style
transform
This element implements the
SVGSwitchElement
接口。
This example demonstrates showing different text content depending on the browser's language settings. The
switch
element will display the first of its child elements whose
systemLanguage
attribute matches the user's language, or the fallback element with no
systemLanguage
attribute if none of them match.
<svg viewBox="0 -20 100 50">
<
switch
>
<
text
systemLanguage
=
"
ar
"
>
مرحبا
</
text
>
<
text
systemLanguage
=
"
de,nl
"
>
Hallo!
</
text
>
<
text
systemLanguage
=
"
en-us
"
>
Howdy!
</
text
>
<
text
systemLanguage
=
"
en-gb
"
>
Wotcha!
</
text
>
<
text
systemLanguage
=
"
en-au
"
>
G'day!
</
text
>
<
text
systemLanguage
=
"
en
"
>
Hello!
</
text
>
<
text
systemLanguage
=
"
es
"
>
Hola!
</
text
>
<
text
systemLanguage
=
"
fr
"
>
Bonjour!
</
text
>
<
text
systemLanguage
=
"
ja
"
>
こんにちは
</
text
>
<
text
systemLanguage
=
"
ru
"
>
Привет!
</
text
>
<
text
>
☺
</
text
>
</
switch
>
</
svg
>
| 规范 |
|---|
|
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
(SVG)
# SwitchElement |
BCD tables only load in the browser
最后修改: , 由 MDN 贡献者