Mobile HTML base value (reprint)

Source: Internet
Author: User

(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)

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.