Some knowledge of the mobile end width

Source: Internet
Author: User

When doing the mobile side, often contact with the word devicepixelratio, the definition of the word is:

Window.devicepixelratio is the ratio of physical pixels and device independent pixels (device-independent pixels (dips)) on the device.

The formula is:

Window.devicepixelratio = physical pixels/dips;

Small conclusion:

When the page <meta name="viewport" content="width=device-width"> is set, document.documentElement.clientWidth in most browsers, the width of the layout viewport is the same as the width of the dips.

① on iOS devices, Window.screen.width returns a dips wide, so the Retina Display's ipad and the non-Retina display ipad return 768 when displayed vertically.

      screen.widthMultiplied by devicePixelRatio the resulting physical pixel value.

② on an Android device, Window.screen.width returns the physical pixel width.

      screen.widthDivided by devicePixelRatio the device independent pixel (dips) value.

devicePixelRatio is trustworthy in most browsers.

Some knowledge of the mobile end width

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.