html{font-size:62.5%}

为什么要使用html,body{font-size:62.5%}?

使用以下代码查看浏览器的初始font-size:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
  <script type="text/javascript">
    var style = document.body.currentStyle || document.defaultView.getComputedStyle(document.body, '')
    console.log(style.fontSize);
  </script>
</body>
</html>

我在不同的浏览器,包括用谷歌浏览器模拟手持设备,得到的值都是16px;

html{font-size:62.5%;}表示设置浏览器文字大小初始值为10px,方便 'px' 转 'em' 或 'px' 转 'rem' 的单位换算。

 

posted @ 2016-11-15 13:57  桃之夭夭~  阅读(679)  评论(0编辑  收藏  举报