Conceptual understanding Viewport Viewport
- Visual viewport visible viewport, device screen width windw.innerwidth/height
- Layout viewport layouts viewport, Dom width Document.documentelement.cliendwidth/heig
Ideal viewport Ideal viewport: The goal is to set the default layout viewport width to the screen width of the mobile device
- Visual viewport = Layout Viewport * Scale
<meta name= "viewport" content= "width=device-width,initial-scale=1" >
Width:viewport width
Initial-scale: page Initial Zoom
Maximum/minimum-scale: Minimum/maximum scale allowed for user scaling
User-scalable:yes/no whether the user is allowed to scale manually
Some things in pixels physical pixels (physical pixel)
Device pixels, the smallest physical part in a device. For example, one screen, twice times screen (Retina), three times times the screen refers to how many physical pixels to display a CSS pixel. Retina screen, a CSS pixel corresponds to 4 physical pixels.
CSS pixels
CSS pixels are abstract units that are used primarily in browsers. CSS is called device-independent pixels (device-independent pixel) abbreviated dips.
Early Iphone3 resolution is the resolution of the 320x480,retina screen 640x960, the screen size is constant but the pixels are increased by one times. At this point, a CSS pixel equals two physical pixels.
Device pixel ratio DPR (pixel ratio)
Device pixel ratio = physical pixel/device independent pixels (IPHONE,DPR = 2 for Retina screen, i.e. 1css pixels equals 2 physical pixels)
The scale and DPR of viewport are reciprocal.
- JavaScript:window.devicePixelRatio
- CSS:-webkit-device-pixel-ration,-webkit-min-device-pixel-ratio,-webkit-max-device-pixel-ratio
The relevant method of front-end adaptation: viewport
Http://caibaojian.com/mobile-responsive-example.html
Https://www.cnblogs.com/2050/p/3877280.html
1190000008767416#articleheader7
Https://github.com/riskers/blog/issues/18
Mobile Web page Adaptation scheme