Mobile-side web compatible with a variety of resolution notation

Source: Internet
Author: User

Mobile Web development best to use REM units, and then set the following JS, to Iphone6 750*1334 as the benchmark

<script>varsize = document.documentelement.clientwidth/750 * 100; //PC-side interview, viewport        if(!/android|webos|iphone|ipod| blackberry/i.test (navigator.useragent)) {Size= 100; } document.documentElement.style.fontSize= size + ' px '; //troubleshoot iOS safari disable scaling invalid problemWindow.onload =function() {Document.addeventlistener (' Gesturestart ',function(e) {e.preventdefault ();            }); Document.addeventlistener (' DblClick ',function(e) {e.preventdefault ();            }); Document.addeventlistener (' Touchstart ',function(event) {if(Event.touches.length > 1) {event.preventdefault ();            }            }); varLasttouchend = 0; Document.addeventlistener (' Touchend ',function(event) {varnow = (NewDate ()). GetTime (); if(Now-lasttouchend <= 300) {event.preventdefault (); } lasttouchend=Now ; }, false); };</script>

Equivalent to setting the font-size:100px in the root HTML element

{    font-size: 100px;}

The font-size of the root HTML will be changed according to the size of the mobile side, thus achieving compatibility with various screen sizes.

{  font-size: . 14rem;   //font is set to 14px  width: 2rem;          Width is set to      200px}

Mobile-side web compatible with a variety of resolution wording

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.