aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/medialist
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/medialist
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/medialist')
-rw-r--r--files/zh-cn/web/api/medialist/index.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/medialist/index.html b/files/zh-cn/web/api/medialist/index.html
new file mode 100644
index 0000000000..4b6ffa97e8
--- /dev/null
+++ b/files/zh-cn/web/api/medialist/index.html
@@ -0,0 +1,69 @@
+---
+title: MediaList
+slug: Web/API/MediaList
+tags:
+ - API
+ - CSSOM
+ - Interface
+ - MediaList
+ - Reference
+translation_of: Web/API/MediaList
+---
+<div>{{APIRef("CSSOM")}}</div>
+
+<p><code><strong>MediaList</strong></code> 接口表示样式表的媒体查询,例如使用了 <code>media</code> 属性的{{htmlelement("link")}} 元素。</p>
+
+<div class="blockIndicator note">
+<p><span class="message-body-wrapper"><span class="message-flex-body"><span class="devtools-monospace message-body"><span class="objectBox objectBox-string"><strong>注意:</strong><code>MediaList</code> 是一个实时列表;使用以下属性或方法更新列表会立刻更新文档的表现。</span></span></span></span></p>
+</div>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{domxref("MediaList.mediaText")}}</dt>
+ <dd>一个字符串转化器,返回一个{{domxref("DOMString")}},以文本形式表示 <code>MediaList</code>,也可以通过这个方法设置新的 <code>MediaList</code>。</dd>
+ <dt>{{domxref("MediaList.length")}} {{readonlyInline}}</dt>
+ <dd>返回 <code>MediaList</code> 中媒体查询的数量。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<dl>
+ <dt>{{domxref("MediaList.appendMedium()")}}</dt>
+ <dd>向 <code>MediaList</code> 中添加一个媒体查询。</dd>
+ <dt>{{domxref("MediaList.deleteMedium()")}}</dt>
+ <dd>从 <code>MediaList</code> 中移除一个媒体查询。</dd>
+ <dt>{{domxref("MediaList.item()")}}</dt>
+ <dd>一个获取函数,返回一个{{domxref("CSSOMString")}},表示文本形式的媒体查询,需要提供媒体查询在 <code>MediaList</code> 中的索引位置。</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<p>下述例子会在控制台记录 <code>MediaList</code> 的文本表示,其来自应用到当前文档的第一个样式表。</p>
+
+<pre class="brush: js">const stylesheets = document.styleSheets;
+let stylesheet = stylesheets[0];
+console.log(stylesheet.media.mediaText);</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSSOM', '#the-medialist-interface', 'MediaList')}}</td>
+ <td>{{Spec2('CSSOM')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.MediaList")}}</p>