标签:|| res eve lis func function rem add bsp
html字体大小随屏幕大小的改变而改变,封装函数如下:
(function(){ ‘use strict‘; setRemUnit(); window.addEventListener(‘resize‘,setRemUnit); function setRemUnit(){ var docEl = document.documentElement; var ratio = 18.75; var viewWidth = docEl.getBoundingClientRect().width || window.innerWidth; docEl.style.fontSize = viewWidth / ratio + ‘px‘; } })();
标签:|| res eve lis func function rem add bsp
原文地址:https://www.cnblogs.com/rickdiculous/p/11564437.html