Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone XR / XS / XS Max CSS media queries

What are the correct CSS media queries used to target Apple's 2018 devices: iPhone XR/XS/XS Max ?

like image 341
nathan Avatar asked Sep 13 '18 20:09

nathan


People also ask

What's the difference between iPhone XR XS and XS Max?

The iPhone XS and XS Max feature the same dual 12-megapixel cameras, with a wide-angle (ƒ/1.8 aperture) lens and and telephoto (ƒ/2.4) aperture. The iPhone XR has a single 12-megapixel wide-angle (ƒ/1.8 aperture) sensor. Those dual sensors give the iPhone XS and XS Max 2x optical zoom, and up to 10x digital zoom.

Why my media query is not working in CSS?

CSS declared inline This may be the reason why your media queries aren't working. That is to say, you may have declared CSS within your HTML document. So if this is the case, simply go through the HTML document and remove the CSS declared inline.

Can you use media queries in CSS?

Using media queries. Media queries are commonly associated with CSS, but they can be used in HTML and JavaScript as well. There are a few ways we can use media queries directly in HTML.

How many media queries should I use in CSS?

Depending on how you layout your site you may need to use more or less queries, as you only need a query for each seperate layout/design of the site. A good choice for basic use would be Smartphone, Tablet, Standard Screen, HD Screen or 4.


1 Answers

iPhone XR

/* 1792x828px at 326ppi */ @media only screen      and (device-width : 414px)      and (device-height : 896px)      and (-webkit-device-pixel-ratio : 2) { } 

iPhone XS

/* 2436x1125px at 458ppi */ @media only screen      and (device-width : 375px)      and (device-height : 812px)      and (-webkit-device-pixel-ratio : 3) { } 

iPhone XS Max

/* 2688x1242px at 458ppi */ @media only screen      and (device-width : 414px)      and (device-height : 896px)      and (-webkit-device-pixel-ratio : 3) { } 



Looking for a specific orientation ?

Portrait

Add the following rule:

    and (orientation : portrait)  

Landscape

Add the following rule:

    and (orientation : landscape)  



References:

  • https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/adaptivity-and-layout/
  • https://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
like image 163
nathan Avatar answered Sep 25 '22 13:09

nathan