Mobile page Adaptation

Source: Internet
Author: User

Front-end development, especially mobile phone screen size of different, how to solve the problem of page adaptation? Here is a summary from a few points. 1. Layout Design of Design manuscript

We are in the H5 page content planning layout design, can not put the important content in too low position or biased, otherwise the front-end layout may appear incomplete content.

In almost all cases, the top status bar and navigation bar are removed when the browser is displayed in full screen.

The iphone's design standard, the status bar and the navigation bar independent pixel height of 40px and 88px respectively.

Since the Android system can change the height of the status bar and navigation bar, the default values are 48px and 100px.

Then the Web content will be squeezed into the blind zone (depending on the layout of the possible extrusion of the viewport, that is, under the visible area) The maximum value of these two systems is 148, the design draft to try to ensure that a single page below 148px no important content.

So on all screen size to display the important content completely, pay attention to the existence of small size mobile phone screen, now most of the smartphone resolution is 640*960px (iphone4 resolution) above, so long as the important content on the blind spot, The calculated maximum security height is 812 (960-148=812).

In this summary, in general, to the existing market on the popular mobile smartphones, single-page rollover (non-extended down the long page) design size of 640*1136, at a height of 812 set a security line (reference lines), the important content of the layout on this security thread.

2, relative unit of REM use

Mobile phone page Design General size is 640, but the phone screen size is not sure, then how to make the mobile phone to adapt to all the mobile page?

There are two general solutions, REM layout and percent layout, and I recommend using the REM layout to make mobile pages

The compatibility of REM layouts:

Mozilla Firefox 3.6+, Apple Safari 5+,google Chrome, ie9+ and opera11+

Ie6-8 still do not use REM, but on the phone side, you can ignore the IE kernel this problem.

The calculation formula of REM

Example: HTML settings font-size:16px, 1rem=16px

The core code is this section of the JS operation, based on the size of the page to control the underlying REM value, the following code is based on jquery:

  

var Windoww = $ (window). Width (), var ratio = windoww/640;$ ("html"). CSS ("fontSize", 100*ratio+ "px"), $ (window). On (" Resize ", function () {    var Windoww = $ (window). width ();    var ratio = windoww/640;    $ ("HTML"). CSS ("fontSize", 100*ratio+ "px");});

  

  

Mobile page Adaptation

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.