(function ( ) { Document.addeventlistener (function () { var html = document.documentelement; var windowwidth = html.clientwidth; = windowwidth/6.4 + ' px '; // equivalent to Html.style.fontSize = windowwidth/640 * + ' px '; false ); }) ();
这个6.4就是根据设计稿的横向宽度640来确定的,假如你的设计稿是750
那么 html.style.fontSize = windowWidth / 7.5 + ‘px‘;
(1) At this point, the base value of the font-size is determined, and know that the Font-size value is the mobile phone devicewidth with the design of the proportion of the value of 100 times times (important)
(2) How to set the width height and margin of the page element
For example: a design with a width height of 140px icon, the left margin is 50px, then its CSS should be written like this
{ width: 1.4rem*/* height: 1.4rem; margin: 0 0 0.5rem;}
Because the HTML font-size is magnified 100 times times, the REM is calculated by dividing the actual pixel of the design manuscript by the 100,140px/100 =1.4rem; The actual pixel size will be calculated automatically by the ratio of devicewidth to the horizontal width of the design draft.
From: http://blog.csdn.net/huang100qi/article/details/49886713
Mobile HTML base value (reprint)