Mobile REM Adaptive

Source: Internet
Author: User

/**
* REM Calculation: Design Figure size px/100 = actual REM Example: 100px = 1rem
*/
!function (window) {

/* Design Document Width */
var docwidth =750;

var doc =Window.document,
Docel = Doc.documentelement,
RESIZEEVT =' Orientationchange 'InchWindow?' Orientationchange ':' Resize ';

var Recalc = (functionRefreshrem () {
var clientwidth = Docel.getboundingclientrect (). width;

/* 8.55: Less than 320px no longer shrinks, 11.2: greater than 420px no longer enlarge */
DocEl.style.fontSize =Math.max (Math.min (* (Clientwidth/docwidth),11.2),8.55) *5 +' PX ';

return refreshrem;
})();

/* Add double screen ID, android 1 */
Docel.setattribute (' DATA-DPR ',Window.navigator.appVersion.match (/IPHONE/GI)?Window.devicepixelratio:1);

if (/IP (HONE|OD|AD)/.test (Window.navigator.userAgent)) {
/* Add iOS Logo */
Doc.documentElement.classList.add (' iOS ');
/ * IOS8 above to add hairline style to HTML for special handling */
if (parseint (window.navigator.appVersion.match (/os (\d+) _ (\d+) _? ( \d+)?/) [1], >= 8)
Doc.documentElement.classList.add (' hairline ');
}

if (!doc.addeventlistener) return;
Window.addeventlistener (resizeevt, Recalc, false);
Doc.addeventlistener (' domcontentloaded ', Recalc, false);

} (window);

Move REM Adaptive

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.