With the prevalence of high-end mobile phones (andriod,iphone,ipod,winphone, etc.), the development of mobile Internet applications is becoming more and more important, and it is the best choice to develop mobile applications with HTML5. However, each phone has a different resolution, different screen size, how to make our development of the application or page size can be suitable for a variety of high-end mobile phone use it? Learning the use of HTML5 viewport can help you do this ... viewport syntax introduction:
<!--HTML Document--
02<meta name= "Viewport"
Content= "
Height = [Pixel_value | device-height],
width = [Pixel_value | device-width],
Initial-scale = Float_value,
Minimum-scale = Float_value,
Maximum-scale = Float_value,
user-scalable = [yes | no],
Ten target-densitydpi = [Dpi_value | device-dpi | high-dpi | medium-dpi | low-dpi]
11 "
12/>
Width controls the size of the viewport, which can specify a value or a special value, such as device-width as the width of the device (in pixels of the CSS when scaled to 100%).
Height
Height and width correspond, specify the heights.
target-densitydpi
A screen pixel density is determined by the screen resolution, usually defined as the number of dots per inch (dpi). Android supports three screen pixel densities: low pixel density, medium pixel density, high pixel density. A low-pixel-density screen has fewer pixels per inch, while a high-pixel-density screen has more pixels per inch. The default screen for Android browser and webview is medium pixel density.
The following is the range of values for the Target-densitydpi property
To prevent Android browser and WebView from scaling your page based on the pixel density of different screens, you can set the target-densitydpi of viewport to device-dpi. When you do this, the page will not scale. Instead, the page is displayed based on the pixel density of the current screen. In this case, you also need to define the width of the viewport to match the width of the device so that your page will fit on the screen.
Initial-scale
Initial scaling. That is, the initial zoom level of the page. This is a floating-point value, which is a multiplier of the page size. For example, if you set the initial zoom to "1.0", then the Web page will show up at 1:1 of the target density resolution. If you set it to "2.0", the page will be enlarged to twice times.
Maximum-scale
Maximum zoom. That is, the maximum allowable zoom level. This is also a floating-point value that indicates the maximum multiplier of the page size compared to the screen size. For example, if you set this value to "2.0", the page can be up to twice times larger than the target size.
User-scalable
The user adjusts the zoom. That is, whether the user can change the page zoom level. If set to Yes, the user is allowed to change it instead of No. The default value is yes. If you set it to No, then both Minimum-scale and Maximum-scale will be ignored because scaling is not possible at all.
All scaling values must be within the range of the 0.01–10.
Cases:
(Set screen width to device width, prevent users from manually resizing)
<meta name= "viewport" content= "Width=device-width,user-scalable=no"/>
(Set the screen density to high frequency, if, low frequency auto-scaling, prohibit the user to manually adjust the zoom)
<meta name= "viewport" content= "width=device-width,target-densitydpi=high-dpi,initial-scale=1.0, minimum-scale= 1.0, maximum-scale=1.0, User-scalable=no "/>
Meta name= "Viewport" property