I am trying to implement alternate layouts for both the iPad/iPhone and older iPhones as well.
I have established that the best method is to use @media
from the CSS3 spec.
As such these are my media queries at the minute:
@media screen and (max-width: 1000px) { ... }
Above is for small desktop and laptop screens.
@media screen and (max-width: 700px) { ... }
Above is for the iPad and VERY small desktop/laptop screens.
@media screen and (max-device-width: 480px) { ... }
Above is for iPhone 3GS- and mobile devices in general.
However, the new iPhone 4 with Steve Jobs's all-singing all-dancing "retina" display means that it has a pixel ratio of 2-1 meaning 1 pixel actually appears to the browser as 2x2 pixels making its resolution (960x640 - meaning it will trigger the iPad layout rather than the mobile device layout) so this requires ANOTHER media query (only so far supported by webkit):
@media screen and (-webkit-min-device-pixel-ratio: 2) { ... }
Now, the thing is... I want my nice shiny new iPhone 4 layout amalgamated with the iPhone 3GS and mobile device layout as they will both have exactly the same inner CSS code,
Therefore making my question;
How do I create an @media
rule that points both the iPhone 4, 3GS and other mobiles to the same styles?
Because the iPhone and iPod touch measure max-device-width
in logical pixels rather than physical pixels even with the Retina display (as they should), the original media query used for the iPhone should be enough:
@media only screen and (max-device-width: 480px) {
/* iPhone CSS rules here */
}
You'll only need (-webkit-min-device-pixel-ratio: 2)
if you need to target the Retina display separately.