0

I have a problem of how to write a correct sentence reflecting full css @media query with screen size and screen orientation (example bellow) with JS window.matchMedia, all I can find is a separate example for size (without orientation) and orientation (without size). What is the right syntax of this CSS example:

 @media only screen and (min-width: 483px) and (orientation: landscape) {}

in this code:

if (window.matchMedia("(orientation: portrait)").matches) {
   // how to add a screen size to this exact code?
}

1 Answers1

3

It is the same as the CSS. That's the point of it.

window.matchMedia("only screen and (min-width: 483px) and (orientation: landscape)").matches
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Does it have to have "only screen and"?, I did't sow this "part" in any documentations or examples @Quentin –  Sep 06 '18 at 17:28
  • And little follow up here, how do I add an `eventListner` for changing screen **orientation**? (I'm new to JS, so I need a little bit of help) –  Sep 06 '18 at 17:37
  • https://stackoverflow.com/questions/5284878/how-do-i-correctly-detect-orientation-change-using-phonegap-on-ios – Quentin Sep 06 '18 at 18:30