Images on different devices of the web app adapt to resolution

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.