Mobile WebApp page Adaptation scheme

Source: Internet
Author: User

Viewport (viewport)Concept

In web browsers, the viewport is the visible portion of the entire document.

The mobile browser renders the page in a virtual "window" (viewport) that is usually wider than the screen, eliminating the need to compress all the pages into a small screen (which disrupts many sites that are not optimized for the mobile side). Users can pan and zoom to explore different areas of the page.
Most mobile browsers use a default viewport width, which means that the viewport will enlarge the page with this size so that all elements are placed in the viewport, rendering the entire page.

Default viewport widths for each browser

Safari

Opera

Android WebKit

Ie

980px

850px

800px

974px

Conversion Formula conversion formula for DP and px px = dp* (dpi/160)

The size of the PX in the equivalent CSS on the phone screen, which is not fixed, but also depends on the DPI of the screen. Because the phone will automatically scale the page according to the DPI to coordinate the ratio between the screen pixels and the size to show the effect, the base value is 160dpi. Meaning 160dpi in the device (general resolution is 320*480), 1DP = 1px. We do not pay attention to what DP is, we are concerned about the PX, the current device dp:px is how much, that is, the page at a resolution above or below 320 width resolution, the corresponding scale (in fact, is a concept, is the WebKit browser to do the scaling, to adapt to different devices. All we have to do is remember 320,1dp=1px, and look down from behind.

What is DP

Density-independent pixels, a physical measurement unit based on a computer coordinate system, represents an abstract pixel and an app for the underlying system, how to convert to physical pixels and 160PPI screen as standard, then 1dp=1px

Dpi/ppi

Pixels per inch

How to calculate resolution

A number of pixels that can be displayed in the cell phone size, for example, the 640*960 resolution means that the width is 960 pixels and the height is 640 pixels.

Screen size

The length of the diagonal of the phone screen, such as a 3.5-inch phone.

Calculation

px = dp* (dpi/160)

330/160=2.0625

1DP equals 2.0625 css px

Viewport parameters
Width Viewport width, the default viewport widths for each browser are different. Range: 200-10,000. can also be set to Device-width
Height Viewport height, Range: 223-10,000 can also be set to Device-height
Initial-scale Zoom value when the page is first displayed, determined by Minimum-scale and Maximum-scale
Minimum-scale Minimum zoom value for page display, default value: 0.25, Range: >0-10.0
Maximum-scale Maximum zoom value on page display, default value: 5.0, Range: >0-10.0
User-scalable Determines whether the user can enlarge or reduce the page. The value is desirable: Yes,no. Default value: Yes. Set to No, you can also prevent the page from scrolling when the text is entered into the text box.
Mobile Device Size List

Http://screensiz.es/phone

Adaptation Program

The 160dpi corresponds to a typical resolution of 320*480

Page plus meta tag

<meta name= "viewport" content= "width=device-width,initial-scale=1.0,
Minimum-scale=1,maximum-scale=1,user-scalable=no ">

Copy the design, scale to 320px width. The 320px*480 is a typical resolution of 160dpi. Because viewport the width of the page to Device-width, the device width is different, but the basic can be in the 320 width of the PSD directly in size, unless some of the length of the device with a wide range of text fields with a responsive layout. At this point the font size can be set to the size of the font after zooming, with PX. Cut the icon on the original, use CSS3 query, and Backgound-size zoom.

For example, a query with a resolution width of 480px: @media All and (-webkit-min-device-pixel-ratio:1.5), Background-size is set proportionally.

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.