From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/svg/attribute/media/index.html | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 files/zh-cn/web/svg/attribute/media/index.html (limited to 'files/zh-cn/web/svg/attribute/media') diff --git a/files/zh-cn/web/svg/attribute/media/index.html b/files/zh-cn/web/svg/attribute/media/index.html new file mode 100644 index 0000000000..ffc594fdb4 --- /dev/null +++ b/files/zh-cn/web/svg/attribute/media/index.html @@ -0,0 +1,90 @@ +--- +title: media +slug: Web/SVG/Attribute/media +translation_of: Web/SVG/Attribute/media +--- +
{{SVGRef}}
+ +

media属性指定只有符合{{Glossary("media query")}}的样式表才会被应用。

+ +

只有一个元素使用这个属性: {{SVGElement("style")}}

+ +
+ + +
<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>
+ +

{{EmbedLiveSample("topExample", "200", "200")}}

+
+ +

Usage notes

+ + + + + + + + + + + + + + + + +
Value<media-query-list>
Default valueall
AnimatableYes
+ +
+
<media-query-list>
+
+

This value holds a media query that needs to match in order for the style sheet to be applied.

+ +

如果没有指定,样式表就会被应用。

+
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName("SVG2", "styling.html#StyleElementMediaAttribute", "media")}}{{Spec2("SVG2")}}Changed the value definition from different media types as defined in CSS 2 to <media-query-list>.
{{SpecName("SVG1.1", "styling.html#StyleElementMediaAttribute", "media")}}{{Spec2("SVG1.1")}}Initial definition
+ +

浏览器兼容性

+ + + +

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

-- cgit v1.2.3-54-g00ecf