Recently in the new book << Mobile Web Handbook >>, the following:
Before the responsive design of the Web, if the Web site for the PC is displayed directly on the phone device, because the screen has a small resolution, it often appears in a horizontal scroll bar, and the font size is small. For a better display, you need to adapt the site to a small screen.
Layout viewport: In the mobile browser, the Web site shows the width of the interface, style;
Visual viewport: In the mobile browser, the user can see the website interface through the mobile phone, can be all, can also be part (have horizontal scroll bar).
The best effect is to confine the layout viewport to the visual viewport, limiting the appearance of the horizontal scroll bar, such as: Before the retina appears, the resolution of the phone screen is 320px/480px and can be adapted to the site design for this resolution level device But then the problem with the retina is that the physical size of the device screen has not changed, but the resolution has changed from 320x480 to 640x960, which makes it a failure to adjust the way the site is developed based on resolution.
At the same time, retina appears in its own purpose is to say: The original 1 pixels display screen replaced by the corresponding 4, the longitudinal direction of the original twice times, in order to achieve high-definition effect. So 640x960 the physical pixels of the screen, the website should still be shown with the effect of 320x480css pixels, so that the CSS pixel becomes the relative unit:
Physical pixel: Hardware screen device The actual longitudinal direction of the lattice of the basic unit, determined by the hardware;
CSS pixels: The basic unit of site design, web design developers do not need to care about hardware-level adaptation, just follow the CSS pixel design layout.
This new noun generates: The device pixel ratio DPR (Devices Pixel Ratio) refers to the ratio of the CSS pixel to the physical pixel, as well as the ratio of the physical pixel size of the screen (640x960 physical pixels) to the desired viewport size (320x480css pixels). DPR can also be decimals, such as 1.5.
The resolution has two units:
DPI: dots per inch, where the number of points refers to the amount of pixels, for the screen, this value is relatively fixed, such as: 96. In this calculation: Resolution = 96dpi * INCH_SIZE;
DPPX: points per pixel (dots per pixel), this unit is not widely supported, on the dpr=2 screen to calculate: Resolution = (96DPI * DPR) * inch_size;
DPR relationship to resolution:
Resolution Reslution and DPR described is actually a thing, just stand on different angles, because the former in mobile support is not very good, so DPR become the de facto standard, and is generally supported. The future of mobile development has been DPR as a reference to narrate.
Viewport in Meta:
<name= "Viewport" content= "Width=device-width, initial-scale=1, Maximum-scale=1, User-scalable=no ">
Device-width is the screen width calculated in physical pixels, such as: DPR is 2, the ideal viewport is 320x480 screen, width is 640;
Width=device-width: Sets the width to the width of the physical pixel, and then adapts to the dpr=2 in the media query;
Moving the chapter viewport viewport