为什么要使用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%}

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
  • 2021-11-30
  • 2021-10-15
猜你喜欢
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案