About the problem of mobile-side adaptation

Source: Internet
Author: User

1. Use REM

2. Meta content is as follows:

<meta charset= "UTF-8" >
<meta name= "viewport" content= "width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1, User-scalable=no ">
<!--prevent your iOS device from dialing a number as a dial-up connection, automatically sending a mailbox, clicking the map--
<meta name= "format-detection" content= "Telephone=no,email=no,adress=no" >
<!--force Full-screen display-
<meta name= "Full-screen" content= "yes" >
<!--turn on support for WebApp-
<meta name= "apple-mobile-web-app-capable" content= "yes" >
<!--the color of the status bar (top bar of the screen) under the Web app, default is defaults (white)--
<meta name= "Apple-mobile-web-app-status-bar-style" content= "Black-translucent" >
<!--prevent the browser from accessing the page content from the cache--
<meta http-equiv= "Pragma" content= "No-cache" >

3, the introduction of JS code:

<script type= "Text/javascript" >
Document.documentElement.style.fontSize = document.documentelement.clientwidth/6.4 + "px";
</script>

4. Introduction of JS File

<script type= "Text/javascript" src= "Js/setfontsize.js" ></script>

The contents are as follows:

(Function (doc, win) {
var docel = doc.documentelement,//Get HTML tags
Orientationchange Direction Change Event
resizeevt = ' orientationchange ' in window? ' Orientationchange ': ' Resize ',
Recalc = function () {
Current Device viewport width
var clientwidth = docel.clientwidth;
if (!clientwidth) return;
docEl.style.fontSize = * (clientwidth/750) + ' px ';
};

if (!doc.addeventlistener) return;
Win.addeventlistener (Resizeevt, Recalc, false);
Doc.addeventlistener (' domcontentloaded ', Recalc, false); Load
}) (document, window);

5. Use REM instead of px

If 750 of the design, 100px on the design diagram

1rem defined on the iphone6 of 375

About the problem of mobile-side 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.