From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/pt-br/web/api/window/matchmedia/index.html | 106 +++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 files/pt-br/web/api/window/matchmedia/index.html (limited to 'files/pt-br/web/api/window/matchmedia') 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 +--- +
{{APIRef}}
+ +

Resumo

+ +

Retorna um novo objeto {{domxref("MediaQueryList")}} representando o resultado analisado da string media query especificada.

+ +

Sintaxe

+ +
mql = window.matchMedia(mediaQueryString)
+ +

onde mediaQueryString é uma string representando a media query para o qual retorna um novo objeto {{domxref("MediaQueryList")}}.

+ +

Exemplo

+ +
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 */
+}
+ +

Este código permite-lhe lidar com as coisas de forma diferente quando a janela é muito estreita.

+ +

Veja Usando media queries a partir do código para mais exemplos.

+ +

Especificações

+ + + + + + + + + + + + + + + + +
EspecificaçõesStatusComment
{{SpecName("CSSOM View", "#dom-window-matchmedia", "Window.matchMedia()")}}{{Spec2("CSSOM View")}}Initial definition
+ +

Compatibilidade do navegador

+ +

{{CompatibilityTable()}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support9{{CompatGeckoDesktop("6.0")}}1012.15.1
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support3.0{{CompatGeckoMobile("6.0")}}{{CompatNo}}12.15
+
+ +

Veja também

+ + -- cgit v1.2.3-54-g00ecf