Mobile page uses REM layout

Source: Internet
Author: User

Ali team's HD layout scheme code

The so-called HD solution is based on the device screen DPR (device pixel ratio, also known as dppx, such as dpr=2, indicating that 1 css pixels are composed of 4 physical pixel points)

Dynamically set the font-size of HTML, and adjust the zoom value of the page according to the device DPR, so as to achieve the HD effect * *.

            var _basefontsize = Basefontsize | |            100; var _fontscale = Fontscale | |            1;            var win = window;            var doc = win.document;            var ua = navigator.useragent;            var matches = Ua.match (/android[\s\s]+applewebkit\/(\d{3})/i); var ucversion = Ua.match (/u3\/(\d+|\.) {5,})            /i); var isuchd = ucversion && parseint (Ucversion[1].split ('. ').            Join ('), >= 80;            var Isios = Navigator.appVersion.match (/(Iphone|ipad|ipod)/gi); var DPR = Win.devicepixelratio | |            1; if (!isios &&!) ( Matches && matches[1] > 534) &&!isuchd) {//If non-iOS, non-Android4.3, non-UC core, do not perform HD, DPR set                is 1;            DPR = 1;            } var scale = 1/DPR;            var Metael = doc.queryselector (' meta[name= "viewport"] ");                if (!metael) {Metael = doc.createelement (' meta ');         Metael.setattribute (' name ', ' viewport ');       Doc.head.appendChild (Metael); } metael.setattribute (' content ', ' width=device-width,user-scalable=no,initial-scale= ' + scale + ', Maximum-scale            = ' + scale + ', minimum-scale= ' + scale);        Doc.documentElement.style.fontSize = _BASEFONTSIZE/2 * DPR * _fontscale + ' px '; })();

Note: Not all places apply REM width best or percent

Mobile page uses REM layout

Related Article

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.