注:1、750为设计图横向尺寸大小2、var fontSize = 100;//100px为1rem3、使用:只要在页面中引入即可
(function() {var designWidth = 750;var fontSize = 100;function resize() {var width = document.documentElement.clientWidth;var size = width / designWidth * fontSize;document.querySelector('html').style.fontSize = size + 'px';}resize();window.onresize = resize;})();