Application of viewport in the development of mobile web

Source: Internet
Author: User

The current mainstream mobile device system includes Android,ios, Symbian,blackberry and Web OS. These system browsers are based on the WebKit core, and WebKit claims to be a full-featured mobile browser that supports HTML + CSS + JavaScript, but because of the difference between the mobile device itself and the PC, the Web page we develop will always have some undesirable place on the mobile device.

Viewport translated into Chinese can be called "viewport", we all know that the mobile device screen is much smaller than the PC, WebKit browser will be a larger "virtual" window mapped to the mobile device screen, the default virtual window for 980 like wide (most of the current site's standard width), Then scale at a certain scale (3:1 or 2:1). That is, when we load a normal Web page, WebKit will load the Web page with a 980-pixel browser standard and then reduce it to a width of 490 pixels. Note that this reduction is a global narrowing, which means that all elements on the page will shrink.

So can we change the WebKit's viewport? Of course, add the following viewport code:

<meta name= "viewport" content= "width=500"/>

So is there a better way? for example, we automatically detect the size of the mobile device screen and then make the content adaptive. Very simple, looks like the code of the face:

<meta name= "viewport" content= "Width=device-width"/>

Device-width will automatically detect the screen width of the mobile device. All page content is adaptive to the mobile device screen.

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.