Viewport summary of mobile front-end development

Source: Internet
Author: User

1. Viewport on mobile devices is the area of the device that can be used to display our pages on the screen, but not the viewable area of the browser. Generally speaking, the viewport on a mobile device is larger than the viewable area of the browser. Browsers on mobile devices will set the default viewport to 980px or 1024px, which will cause the browser to appear with a horizontal scroll bar.

1px in 2.css is not equal to the 1px of the device. The larger the resolution, the more physical pixels the 1px represents in the CSS.

3. Three Viewpor theory: layout viewport; visual Viewpoint,ideal VIEWP.

Layout viewport: If the viewable area of the browser on the mobile device is set to viewport, some websites will show confusion because the viewport is too narrow, so these browsers decide to set viewport to a wide value by default, such as 980px, In this way, even those websites designed for the desktop can be displayed on the mobile browser normally. PPK The default viewport of this browser is called Layout viewport. the width of this layout viewport can be obtained through document.documentElement.clientWidth .

Visual viewport: The size of the viewable area of the browser, which can be obtained by copper through window.innerwidth.

Ideal viewport: Perfect for the viewport of a mobile device, its width equals the screen width of the mobile device. The jquery mobile framework is designed to adapt the interface to a variety of mobile devices, with no horizontal scroll bars on any mobile device.

4. Use META tags to control viewpoint.

The mobile device defaults to layout viewport, which is wider than the screen. Want to achieve ideal viewport effect

<meta name= "viewport" content= "Width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" >

On both the iphone and ipad, the width of the ideal viewport is the width of the vertical screen, whether it is a vertical screen or a horizontal screen.
Similarly: <meta name= "viewport" content= "initial-scale=1" > can also be implemented to change the current viewport ideal viewport. But this time, the Windows Phone on the screen, whether vertical or horizontal screen is set to the width of the vertical screen ideal viewport width.

So the perfect solution: compatible with IE and iphone.
<meta name= "viewport" content= "Width=device-width, initial-scale=1" >

5. On the iphone and ipad, no matter how wide you set the viewport, if you don't specify a default scaling value, the iphone and ipad will automatically calculate this scaling value to reach the current page without a horizontal scroll bar ( Or the width of the viewport is the width of the screen).

Source: http://www.cnblogs.com/2050/p/3877280.html.

Viewport summary of mobile front-end development

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.