Viewport found the parameters of millet phone inconsistent

Source: Internet
Author: User

  A small partner who wants to study in the field of mobile web, the first thing to pass is the relationship between the logical pixels and the device pixels.

First into the mobile web, must understand a few units (DPI, PPI, DP, PX detailed calculation method and the source of the algorithm?) ):

    • Dip (DP): device independent pixels (devices independent pixels), is an Android development unit, 1DP indicates the 1px length at a screen point density of 160ppi.
    • Dpi:dot per inch,dpi is the dot per inch, the number of dots, and the PPI is Pixel per inch, pixel-to-pixel, for the monitor design, Dpi=ppi.
    • Ppi:pixels per Inch,ppi Indicates the point density of the display device, and DPI represents the print point density.
    • Px:pixel, this is what we always call css pixels.
    • DPR: Represents the device scaling ratio

The transformation formula from the device pixel to the logical pixel is:

    1px = 1DP *= ppi/160= sqrt (w*w + H * H)/screen size;

where W and H are in DP, the screen size usually refers to the diagonal length in inches (which is calculated by diagonal, because the diagonal length of the screen (screen size) is the exact value that is set by the manufacturer. Both width and height need to be calculated to obtain ).

We first use the above formula to calculate phone6 css pixels:

The Iphone6 parameter is: 4.7 inch, Resolution: 1334 * 750

The PPI for Iphone6 is: sqrt (1334 * 1334 + 750 * 750)/4.7 = 325.612 .....

The DPR of iphone6 is: 325.612/160 = 2.03 ...

So the iphone6 CSS pixel is: 667 * 375

Then use the Xiaomi 4c phone at hand to calculate:

  

According to official website data, 441ppi is DPR 2.75625, then the Xiaomi 4c CSS Pixel is: 696 * 391.

Next we will pass viewport to verify that our results are correct.

First set up the META tag to control viewport:

<meta name= "viewport" content= "Width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" >

For students who have questions about viewport, please read this article: The viewport of mobile front-end development in-depth understanding

Then set the width of the image:

Iphone6:

Xiaomi 4c:

The results of the test run are:

Iphone6 exactly as expected: But Xiaomi 4 gets the result

You can see that the Xiaomi phone has a scroll bar, which means that according to the official data we get the result is wrong. Asked about the millet work buddies, learned that their design is 720-standard, but CSS pixels is certainly not 720px, whether it is possible to 360, the width of the image is set to 360px found perfect match.

According to the results of 360, assuming that the Xiaomi official 441ppi is accurate, we push the screen resolution found to not reach 1920 * 1080 at all.

That makes people wonder, then I read the Window.devicepixelradio, found that the Xiaomi phone Chrome browser results are 3.

Alert (Window.devicepixelratio)

Based on the results of the Devicepixelradio, it is found that the 1080p screen resolution is fully compliant, so the PPI data is definitely wrong.

This is too pit, remember that year lei June vowed to say, millet in 10 years to surpass Apple. But the egg, from the results of this matter alone, rebels more need to lead the company down to do things to be worthy of their own boast of the Haikou.

Viewport found the parameters of millet phone inconsistent

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.