Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is correct media query for IPad Pro?

I have these two but they are not working. I'm simulating in Chrome

    /* Landscape*/      @media only screen and (min-device-width: 1024px) and (max-device-width: 1366px) and (-webkit-min-device-pixel-ratio: 2)  and (orientation: landscape)  {}      /* Portrait*/     @media only screen and (min-device-width: 1024px) and (max-device-width: 1366px) and (-webkit-min-device-pixel-ratio: 2)  and (orientation: portrait)  {} 

If I remove 'and (orientation: landscape)' then the css in there works in the first media query. What is the correct orientation, for both landscape and portrait ?

The HTML meta is set as

<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> 
like image 346
Rory Avatar asked Feb 01 '17 11:02

Rory


People also ask

Is media query still used?

And even though media queries are still a valid tool to create responsive interfaces, there are many situations where it's possible to avoid using width at all. Modern CSS allow us to create flexible layouts with CSS grid and flex that adapts our content to the viewport size without a need to add breakpoints.


2 Answers

/* ----------- iPad Pro ----------- */ /* Portrait and Landscape */ @media only screen    and (min-width: 1024px)    and (max-height: 1366px)    and (-webkit-min-device-pixel-ratio: 1.5) { }  /* Portrait */ @media only screen    and (min-width: 1024px)    and (max-height: 1366px)    and (orientation: portrait)    and (-webkit-min-device-pixel-ratio: 1.5) { }  /* Landscape */ @media only screen    and (min-width: 1024px)    and (max-height: 1366px)    and (orientation: landscape)    and (-webkit-min-device-pixel-ratio: 1.5) {  } 

I don't have an iPad Pro but this works for me in the Chrome simulator.

like image 64
nykon333 Avatar answered Sep 30 '22 09:09

nykon333


/* Landscape*/  @media only screen and (min-device-width: 1366px) and (max-device-height: 1024px) and (-webkit-min-device-pixel-ratio: 2)  and (orientation: landscape)  {}  /* Portrait*/ @media only screen and (min-device-width: 1024px) and (max-device-height: 1366px) and (-webkit-min-device-pixel-ratio: 2)  and (orientation: portrait)  {} 

Portrait medias query for iPad Pro should be fine as it is.

Landscape media query for iPad Pro (min-device-width) should be 1366px and (max device-height) should be 1024px.

Hope this helps.

like image 25
Daniel T. Avatar answered Sep 30 '22 10:09

Daniel T.