Getting Started with mobile development-basics

Source: Internet
Author: User

1. Some concepts

DP, PT

Device-independent pixels device-independent pixels, a physical unit measured based on a coordinate system within the device, represents a virtual pixel that can be used by a program, and then converted from the underlying system to a logical pixel (Wikipedia has no way to turn it ...) )

Dpr

Devicepixelratio device pixel scaling ratio, can be obtained by Window.devicepixelradio

Layout-viewport

Layout viewport, browser manufacturers in order to fully display the page designed for PC virtual layer, the width is larger than the width of the browser, the specific device manufacturers decide.

The width of the layout-viewport can be obtained from the following JS

var width = document.documentElement.clientWidth;

The following are the default viewport sizes for some devices

A picture of the layout viewport is then pasted to make it easier to understand

Visual-viewport

Visual viewport, the viewable area of the browser, the user can scale to resize it without changing the size of the layout viewport

The width of the visual-viewport can be obtained by the following JS

var width = window.innerwidth;

Ideal-viewport

Ideal viewport, the browser can be perfectly adapted to the mobile device's viewport, so-called perfect fit is the user does not need to zoom and use the scroll bar to see the entire content of the page, and the size of the text and pictures regardless of the resolution can be displayed.

The size of the ideal viewport varies by device, and all iphone devices have a ideal-viewport of 320px, regardless of their screen width.

That means the width of the ideal-viewport is equal to the width of the screen

2. Meta tags

Property list:

Width:device-width | Numerical

Initial-scale: initial zoom ratio,

Maximum-scale|minimum-scale: Max/min zoom ratio

User-scalable:no|yes

Set current viewport to Ideal-viewport

<name= "Viewport"  content= "Width=device-width">

Or

<name= "Viewport"  content= "initial-scale=1"> 

The indirect explanation here is that Initial-scale is scaled relative to ideal-viewport.

Attention:

When the Initial-scale is in conflict with width, the width and ideal-viewport which are large are used which
However, when UC9 is initial-scale=1, the width of the viewport is always the width of the ideal viewport, regardless of the value of the Width property.

Therefore, the more perfect wording should be:

<name= "Viewport"  content= "initial-scale=1, width=device-width"  >

3. Zoom

As mentioned above, scaling is scaled relative to Ideal-viewport, and the size of the visual-viewport is scaled, the larger the scale, the smaller the visual-viewport size, and a chestnut:

Ideal-viewport = 320px, Initial-scale = 2, visual-viewport width is 320px/2 = 160px;

Scaling does not change the width of the screen (nonsense), just stretched a CSS pixel, originally a CSS pixel only accounted for 1 physical pixels, because the page was magnified twice times, a CSS pixel now to occupy 4 physical pixels, so the screen visible area is Visual-viewport The width is equal to half the original.

Attention:

On the iphone and ipad, regardless of the width you set for layout viewpor, and without specifying the initial zoom value, the iphone and ipad automatically calculate the value of Initial-scale to ensure that the current layout The width of the viewport is scaled to the width of the viewable area of the browser, meaning that no horizontal scroll bars appear.

iphone under Layout-viewport = 980, Ideal-viewport = 320

Initial-scale = Ideal-viewport/layout-viewport;

The default value is around 0.33, and when we set the Initial-scale, the browser will not use this default value.

Reference URL: Viewport Details-Jane book, A tale of the Viewports-part one

Getting Started with mobile development-basics

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.