diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/api/window/matchmedia | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/fr/web/api/window/matchmedia')
-rw-r--r-- | files/fr/web/api/window/matchmedia/index.html | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/files/fr/web/api/window/matchmedia/index.html b/files/fr/web/api/window/matchmedia/index.html new file mode 100644 index 0000000000..1237675eeb --- /dev/null +++ b/files/fr/web/api/window/matchmedia/index.html @@ -0,0 +1,77 @@ +--- +title: window.matchMedia +slug: Web/API/Window/matchMedia +translation_of: Web/API/Window/matchMedia +--- +<div> + {{ApiRef}}</div> +<h2 id="Summary" name="Summary">Résumé</h2> +<p>Retourne un nouvel objet {{domxref("MediaQueryList")}} contenant les résultats de la chaîne de caractères <a href="/en-US/docs/CSS/Media_queries" title="CSS/Media queries">media query</a> spécifiée.</p> +<h2 id="Syntax" name="Syntax">Syntaxe</h2> +<pre class="syntaxbox"><em>mql</em> = window.matchMedia(<em>mediaQueryString</em>)</pre> +<p>Ici, <code>mediaQueryString</code> est une chaîne de caractère représentant la media query pour laquelle on retourne un nouvel objet {{domxref("MediaQueryList")}}.</p> +<h2 id="Example" name="Example">Exemple</h2> +<pre class="brush: js">if (window.matchMedia("(min-width: 400px)").matches) { + /* the view port is at least 400 pixels wide */ +} else { + /* the view port is less than 400 pixels wide */ +}</pre> +<p>Ce code permet de gérer la mise en page d'une manière différente quand l'écran est moins large.</p> +<p>Voir <a href="/en-US/docs/DOM/Using_media_queries_from_code" title="/en-US/docs/DOM/Using_media_queries_from_code">Utiliser les media queries avec du code</a> pour plus d'exemples.</p> +<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilité des navigateurs</h2> +<p>{{CompatibilityTable()}}</p> +<div id="compat-desktop"> + <table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>9</td> + <td>{{CompatGeckoDesktop("6.0")}}</td> + <td>10 PP3 {{property_prefix("ms")}}</td> + <td>{{CompatNo()}}</td> + <td>5.1</td> + </tr> + </tbody> + </table> +</div> +<div id="compat-mobile"> + <table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>3.0</td> + <td>{{CompatGeckoMobile("6.0")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>5</td> + </tr> + </tbody> + </table> +</div> +<h2 id="Specification" name="Specification">Spécification</h2> +<ul> + <li><a class="external" href="http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface">The CSSOM View Module: The MediaQueryList Interface</a></li> +</ul> +<h2 id="See_also" name="See_also">Voir aussi</h2> +<ul> + <li><a href="/en-US/docs/CSS/Media_queries" title="CSS/Media queries">Media queries</a></li> + <li><a href="/en-US/docs/DOM/Using_media_queries_from_code" title="CSS/Using media queries from code">Using media queries from code</a></li> + <li>{{domxref("MediaQueryList")}}</li> + <li>{{domxref("MediaQueryListListener")}}</li> +</ul> |