aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/mediaquerylist/matches/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ja/web/api/mediaquerylist/matches/index.html')
-rw-r--r--files/ja/web/api/mediaquerylist/matches/index.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/files/ja/web/api/mediaquerylist/matches/index.html b/files/ja/web/api/mediaquerylist/matches/index.html
new file mode 100644
index 0000000000..c45ac010cf
--- /dev/null
+++ b/files/ja/web/api/mediaquerylist/matches/index.html
@@ -0,0 +1,90 @@
+---
+title: MediaQueryList.matches
+slug: Web/API/MediaQueryList/matches
+tags:
+ - API
+ - Adaptive Design
+ - CSSOM
+ - CSSOM View
+ - DOM
+ - Media Queries
+ - MediaQueryList
+ - Property
+ - Reference
+ - matches
+ - アダプティブデザイン
+ - プロパティ
+ - メディアクエリ
+translation_of: Web/API/MediaQueryList/matches
+---
+<p>{{APIRef("CSSOM")}}</p>
+
+<p><strong><code>matches</code></strong> は {{DOMxRef("MediaQueryList")}} インターフェイスの読み取り専用プロパティで、 {{jsxref("Boolean")}} であり、文書が現在メディアクエリリストと一致している場合は <code>true</code> を返し、一致していない場合は <code>false</code> を返します。</p>
+
+<p><code>matches</code> の値が変化した場合は、 <code>MediaQueryList</code> で発生する {{domxref("MediaQueryList.change_event", "change")}} イベントを監視することで通知を受けることができます。</p>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<pre class="syntaxbox notranslate">var <var>matches</var> = &lt;varm&gt;MediaQueryList.matches;</pre>
+
+<h3 id="Value" name="Value">値</h3>
+
+<p>{{DOMxRef("Boolean")}}。 {{DOMxRef("document")}} が現在メディアクエリーのリストに一致していれば <code>true</code> を返し、そうでなければ <code>false</code> を返します。</p>
+
+<h2 id="Example" name="Example">例</h2>
+
+<p>この例では <code><a href="/ja/docs/Web/CSS/@media/orientation">orientation</a></code> メディア特性を使用したメディアクエリを作成することにより、ビューポートの向きの変化を検出します。</p>
+
+<pre class="brush: js notranslate">function addMQListener(mq, callback) {
+ if (mq.addEventListener) {
+ mq.addEventListener("change", callback);
+ } else {
+ mq.addListener(callback);
+ }
+}
+
+addMQListener(window.matchMedia("(orientation:landscape)"),
+ event =&gt; {
+ if (event.matches) {
+ /* 横向きの画面になった */
+ } else {
+ /* 縦向きの画面になった */
+ }
+ }
+);
+</pre>
+
+<h2 id="Specifications" name="Specifications">仕様書</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">仕様書</th>
+ <th scope="col">状態</th>
+ <th scope="col">備考</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("CSSOM View", "#dom-mediaquerylist-matches", "matches")}}</td>
+ <td>{{Spec2("CSSOM View")}}</td>
+ <td>編集者草稿</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
+
+<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div>
+
+<p>{{Compat("api.MediaQueryList.matches")}}</p>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li><a href="/ja/docs/CSS/Media_queries">メディアクエリ</a></li>
+ <li><a href="/ja/docs/CSS/Using_media_queries_from_code">コードからのメディアクエリの使用</a></li>
+ <li>{{DOMxRef("window.matchMedia()")}}</li>
+ <li>{{DOMxRef("MediaQueryList")}}</li>
+ <li>{{DOMxRef("MediaQueryListEvent")}}</li>
+</ul>