I am using the media query in css to differentiate iphone and ipad
Here’s my code:
/* iphone 3 */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) and (orientation:portrait) { ... }
/* iphone 4 */
@media only screen and (min-device-width : 640px) and (max-device-width : 960px) and (orientation:portrait) { ... }
/*iPad styles*/
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation:portrait) { ... }
/* i have the same for landscape */
Now I have a resolution conflict, the iphone 4 use the same resolution as the ipad and vice versa.
How can I fix this?
Modify your iPhone 4 media query to target high density pixel displays (retina = iPhone4)
Didn’t notice you reopened the question with an expansion so here is a reworked answer to target both iphones (3 and 4) and ipads.
Breakdown of what you should expect:
tealbackground color.orangeon an ipad (landscape).blackon an ipad (portrait)redon an iphone 4 (portrait)pinkon an iphone 4 (landscape)greenon regular smartphones, e.g Androids (landscape)purpleon a regular smartphone (portrait)CSS
I reformatted the
@mediaqueries found in this fine article over at CSS-tricks to comply to some iphone4-specific bits, but overall this media query set should cover both iphones (3 and 4 with separate media queries) and ipads as well.Here is a demo you can try in your i-devices.
http://jsfiddle.net/andresilich/SpbC3/4/show/
And you can also try out the queries over at http://quirktools.com/screenfly/ to see how they stack up. One thing though, the screenfly site does not differentiate between iphone 3 and 4 because regular browsers skip the
webkitonly-webkit-min-device-pixel-ratio : 1.5pixel ratio count so you will get better results testing it out in your actual device.