移动端自适应 px转rem 实现响应式屏幕

在做移动端开发,h5开发时,会需求屏幕的自适应;因此就需要用到rem、em、vw、或者%;
本文简述一下html文本中rem的使用方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script>
!function () {
var pageWid = 750;
function a() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / pageWid * 10 / 16 * 1000 + "%"
}
var b = null;
window.addEventListener("resize", function () {
clearTimeout(b);
b = setTimeout(a, 100)
}, !1);
a()
}(window);
</script>

  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2020-2021 前端老猫
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信