The concept of physical/css/bit image and the realization of REM layout in mobile terminal

Source: Internet
Author: User

Knowledge of this area has been smattering. I have seen some articles before, and there is no sense of enlightened. Today read this http://div.io/topic/1092 feel understand some, whether or not correct, first record, left to be verified later.

1. Physical pixels, css pixels, and bit images

The physical pixel is the smallest display unit that the device itself uses to render the screen. We usually buy mobile phones, such as iphone6 or Huawei to see 720 * 1080, 1080 * 1920 are actually physical pixels. Obviously the physical pixel is not equal to the screen width understood by the PC front-end development.

CSS pixels are virtual pixels that are used when programming. My understanding is that CSS pixels are based on the screen width.

If a visual designer is designed with a 720 canvas, all the dimensions in the design are based on physical pixels, which means they should be proportional to the physical pixels. When writing CSS code on the front-end, the values of the CSS code should be set on the screen size as a benchmark. For native DPR is the 2 screen, the 1css pixel points are represented by 4 physical pixels. The 1px border of the retina screen,

In fact, the original intention of the designer is 1 physical pixels. It is conceivable that for programmers, the CSS should be implemented in the 0.5 CSS pixel border, which is why the designer always feel that the dpr=2 screen 1px line is very thick.

Bit image is the concept used when working with high-definition images. When 1 physical pixels can represent a 1-bit image, the picture is clear. What we usually call X2 times is based on CSS pixels. So, based on a graph with a twice-fold magnification of the CSS pixel, converting it to a physical pixel below the retina is equivalent to a 1-bit pixel corresponding to 1 physical pixels, it will be clear.

2. REM Layout

The way of REM layout is to set the HTML font-size. Base value calculation: Document.documentElement.clientWidth * DPR/10. Write the Pxtorem function.

The principle of layout is: Visual manuscript size/physical pixel = CSS pixel value/screen width. So CSS pixel value = visual size/real DPR.

The concept of physical/css/bit image and the realization of REM layout in mobile terminal

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.