aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/element/style/index.html
blob: fab606a81da685d709e6c7c819730aef70b2620b (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
---
title: style
slug: Web/SVG/Element/style
tags:
  - SVG
  - 元素
  - 参考
translation_of: Web/SVG/Element/style
---
<div>{{SVGRef}}</div>

<p><code>style</code>元素元素样式表直接在SVG内容中间嵌入。SVG的<code>style</code>元素的属性与HTML中的相应的元素并无二致(请阅读HTML的 {{HTMLElement("style")}} 元素)。</p>

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

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

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

<pre class="brush: html">&lt;svg width="100%" height="100%" viewBox="0 0 100 100"
     xmlns="http://www.w3.org/2000/svg"&gt;
  &lt;style&gt;
    /* &lt;![CDATA[ */
    circle {
      fill: orange;
      stroke: black;
      stroke-width: 10px; // Note that the value of a pixel depend on the viewBox
    }
    /* ]]&gt; */
  &lt;/style&gt;

  &lt;circle cx="50" cy="50" r="40" /&gt;
&lt;/svg&gt;
</pre>

<p>示例输出</p>

<p>{{EmbedLiveSample("Example",150,165)}}</p>

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

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

<ul>
 <li><a href="/en-US/SVG/Attribute#Core">核心属性</a> »</li>
</ul>

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

<ul>
 <li>{{SVGAttr("type")}}</li>
 <li>{{SVGAttr("media")}}</li>
 <li>{{SVGAttr("title")}}</li>
</ul>

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

<p>该元素实现了<code><a href="/en-US/DOM/SVGStyleElement">SVGStyleElement</a></code>接口。</p>

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

{{Compat("svg.elements.style")}}

<h2 id="参见">参见</h2>

<ul>
 <li><a href="/en-US/HTML/Element/style">HTML中的<code>&lt;style&gt;</code>元素</a></li>
</ul>