The iPhone 5 has a longer screen and it's not catching my website's mobile view. What are the new responsive design queries for the iPhone 5 and can I combine with existing iPhone queries?
My current media query is this:
@media only screen and (max-device-width: 480px) {}
Another useful media feature is
device-aspect-ratio
.Note that the iPhone 5 does not have a 16:9 aspect ratio. It is in fact 40:71.
iPhone < 5:
@media screen and (device-aspect-ratio: 2/3) {}
iPhone 5:
@media screen and (device-aspect-ratio: 40/71) {}
iPhone 6:
@media screen and (device-aspect-ratio: 375/667) {}
iPhone 6 Plus:
@media screen and (device-aspect-ratio: 16/9) {}
iPad:
@media screen and (device-aspect-ratio: 3/4) {}
Reference:
Media Queries @ W3C
iPhone Model Comparison
Aspect Ratio Calculator
All these answers listed above, that use
max-device-width
ormax-device-height
for media queries, suffer from very strong bug: they also target a lot of other popular mobile devices (probably unwanted and never tested, or that will hit the market in future).This queries will work for any device that has a smaller screen, and probably your design will be broken.
Combined with similar device-specific media queries (for HTC, Samsung, IPod, Nexus...) this practice will launch a time-bomb. For debigging, this idea can make your CSS an uncontrolled spagetti. You can never test all possible devices.
Please be aware that the only media query always targeting IPhone5 and nothing else, is:
Note that exact width and height, not max-width is checked here.
Now, what is the solution? If you want to write a webpage that will look good on all possible devices, the best practice is to you use degradation
/* degradation pattern we are checking screen width only sure, this will change is turning from portrait to landscape*/
If more than 30% of your website visitors come from mobile, turn this scheme upside-down, providing mobile-first approach. Use
min-device-width
in that case. This will speed up webpage rendering for mobile browsers.iPhone 5 in portrait & landscape
iPhone 5 in landscape
iPhone 5 in portrait
afaik no iPhone uses a pixel-ratio of 1.5
iPhone 3G / 3GS: (-webkit-device-pixel-ratio: 1) iPhone 4G / 4GS / 5G: (-webkit-device-pixel-ratio: 2)
You should maybe down the "-webkit-min-device-pixel-ratio" to 1.5 to catch all iPhones ?