diff options
Diffstat (limited to 'files/pt-br/web/api/window/matchmedia/index.html')
-rw-r--r-- | files/pt-br/web/api/window/matchmedia/index.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/files/pt-br/web/api/window/matchmedia/index.html b/files/pt-br/web/api/window/matchmedia/index.html new file mode 100644 index 0000000000..a6497ded0a --- /dev/null +++ b/files/pt-br/web/api/window/matchmedia/index.html @@ -0,0 +1,106 @@ +--- +title: Window.matchMedia() +slug: Web/API/Window/matchMedia +translation_of: Web/API/Window/matchMedia +--- +<div>{{APIRef}}</div> + +<h2 id="Summary" name="Summary">Resumo</h2> + +<p>Retorna um novo objeto {{domxref("MediaQueryList")}} representando o resultado analisado da string <a href="/en-US/docs/CSS/Media_queries" title="CSS/Media queries">media query</a> especificada.</p> + +<h2 id="Syntax" name="Syntax">Sintaxe</h2> + +<pre class="syntaxbox"><em>mql</em> = window.matchMedia(<em>mediaQueryString</em>)</pre> + +<p>onde <code>mediaQueryString</code> é uma string representando a media query para o qual retorna um novo objeto {{domxref("MediaQueryList")}}.</p> + +<h2 id="Example" name="Example">Exemplo</h2> + +<pre class="brush: js">if (window.matchMedia("(min-width: 400px)").matches) { + /* a viewport tem pelo menos 400 pixels de largura */ +} else { + /* a viewport menos que 400 pixels de largura */ +}</pre> + +<p>Este código permite-lhe lidar com as coisas de forma diferente quando a janela é muito estreita.</p> + +<p>Veja <a href="/en-US/docs/DOM/Using_media_queries_from_code" title="CSS/Using media queries from code">Usando media queries a partir do código</a> para mais exemplos.</p> + +<h2 id="Specifications" name="Specifications">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificações</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("CSSOM View", "#dom-window-matchmedia", "Window.matchMedia()")}}</td> + <td>{{Spec2("CSSOM View")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidade do navegador</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</td> + <td>12.1</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>12.1</td> + <td>5</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also" name="See_also">Veja também</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">Usando media queries a partir do código</a></li> + <li>{{domxref("MediaQueryList")}}</li> + <li>{{domxref("MediaQueryListListener")}}</li> +</ul> |