[Viewport] compatibility of mobile devices and viewport

Source: Internet
Author: User

[Viewport] compatibility of mobile devices and viewport
Some time ago, when I used a developer tool to reconstruct a menu project, I found the problem of incomplete display and layout disorder, and found a simple and crude solution. The viewports on mobile devices are dividedLayout viewport,Visual viewport And Ideal viewportAmong them, ideal viewport is the most suitable viewport for mobile devices. The width of ideal viewport is equal to the screen width of mobile devices, as long as the width of an element in css is set to the width of ideal viewport (unit: px), the width of this element is the width of the device screen, that is, the effect of 100% in width. The significance of ideal viewport is that, no matter what resolution screen, Websites designed for ideal viewport do not require manual scaling or horizontal scroll bars, can be perfectly presented to users. Because the ideal viewport width of all iPhones is 320px, the simple and crude method for adapting H5 pages to all iphone phones and Android models is as follows: set viewport <meta name = "viewport" content = "width = 320, maximum-scale = 1.3, user-scalable = no "> meta viewport label is first introduced by Apple in its safari browser to solve the viewport problem of mobile devices. Later, Android and various browser vendors followed suit and introduced support for meta viewport, which proved to be very useful. In Apple's specifications, meta viewport has six attributes (for the moment, those in content are called attributes and values), as follows:

Width SetLayout viewportIs a positive integer or string "width-device"
Initial-scale Set the initial scaling value of the page to a number with decimals.
Minimum-scale The minimum scaling value of a user, which is a number with decimal digits.
Maximum-scale The maximum scaling value of a user, which is a number with decimal digits.
Height SetLayout viewportThis attribute is not important to us and is rarely used.
User-scalable Whether to allow scaling. The value is "no" or "yes". "no" indicates no, and "yes" indicates allow.
These attributes can be used at the same time, or separately or in combination. Separate multiple attributes with commas.

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.