blob: ffc594fdb49830af85f66e4282b8c120d234dce6 (
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
|
---
title: media
slug: Web/SVG/Attribute/media
translation_of: Web/SVG/Attribute/media
---
<div>{{SVGRef}}</div>
<p><span class="seoSummary"><code><strong>media</strong></code>属性指定只有符合{{Glossary("media query")}}的样式表才会被应用。 </span></p>
<p>只有一个元素使用这个属性: {{SVGElement("style")}}</p>
<div id="topExample">
<div class="hidden">
<pre class="brush: css">html, body, svg {
height: 100%;
}</pre>
</div>
<pre class="brush: html; highlight[5]"><svg viewBox="0 0 240 220" xmlns="http://www.w3.org/2000/svg">
<style>
rect { fill: black; }
</style>
<style media="all and (min-width: 600px)">
rect { fill: seagreen; }
</style>
<text y="15">Resize the window to see the effect</text>
<rect y="20" width="200" height="200" />
</svg></pre>
<p>{{EmbedLiveSample("topExample", "200", "200")}}</p>
</div>
<h2 id="Usage_notes">Usage notes</h2>
<table class="properties">
<tbody>
<tr>
<th scope="row">Value</th>
<td><code><a href="/en-US/docs/Web/CSS/@media#media-query-list"><media-query-list></a></code></td>
</tr>
<tr>
<th scope="row">Default value</th>
<td><code>all</code></td>
</tr>
<tr>
<th scope="row">Animatable</th>
<td>Yes</td>
</tr>
</tbody>
</table>
<dl>
<dt><code><media-query-list></code></dt>
<dd>
<p>This value holds a media query that needs to match in order for the style sheet to be applied.</p>
<p>如果没有指定,样式表就会被应用。</p>
</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName("SVG2", "styling.html#StyleElementMediaAttribute", "media")}}</td>
<td>{{Spec2("SVG2")}}</td>
<td>Changed the value definition from different media types as defined in CSS 2 to <code><a href="/en-US/docs/Web/CSS/@media#media-query-list"><media-query-list></a></code>.</td>
</tr>
<tr>
<td>{{SpecName("SVG1.1", "styling.html#StyleElementMediaAttribute", "media")}}</td>
<td>{{Spec2("SVG1.1")}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("svg.elements.style.media")}}</p>
|