John Grober: I don't think mobilesafari will render images point-by-point, because the pixel sizes between the new and old iPhones are extremely large.
Dave hairt: Most designers are still stuck in the traditional idea: CSS pixels are screen pixels. However, when we enter the world of high DPI, the user interface may be enlarged as a whole, and one CSS pixel occupies multiple screen pixels. The iPhone 3 and iPhone 4 are the most typical pictures or icons. When the iPhone 3 is clearly displayed, the iPhone 4 is blurred and helpless. You can only prepare two sets of pictures. Fortunately, the media attribute provided by CSS allows us to easily identify devices with different DPI and apply different styles. First, let's take a look at the common iPhone and Android screen parameters.
Device |
Resolution |
Device pixel Ratio |
Android ldpi |
320 × 240 |
0.75 |
IPhone 3 & Android mdpi |
320 × 480 |
1 |
Android hdpi |
480 × 800 |
1.5 |
IPhone 4 |
960 × 640 |
2.0 |
It can be seen that a CSS pixel of iPhone 4 is actually a 2 × 2 pixel. Therefore, the image is blurred as if it were magnified twice.
Solution: 1. Page reference
< Link REL = "Stylesheet" Media = "Screen and (-WebKit-device-pixel-ratio: 0.75 )" Href = "Ldpi.css" /> < Link REL = "Stylesheet" Media = "Screen and (-WebKit-device-pixel-ratio: 1.0 )" Href = "Mdpi.css" /> < Link REL = "Stylesheet" Media = "Screen and (-WebKit-device-pixel-ratio: 1.5 )" Href = "Hdpi.css" /> < Link REL = "Stylesheet" Media = "Screen and (-WebKit-device-pixel-ratio: 2.0 )" Href = "Retina.css" />
2. In the CSS file
# Header{Background:URL (mdpi/bg.png);}@ Media screen and (-WebKit-device-pixel-ratio: 1.5){/*CSS for high-density screens*/# Header {background:URL (hdpi/bg.png);}}
Note: This article from http://bbs.blueidea.com/home.php? MoD = Space & uid = 168495 & Do = Blog & id = 23366