自动计算代码:注意单位使用rem
var htmlWidth = document.documentElement.clientWidth || document.body.clientWidth
var htmlDom = document.getElementsByTagName("html")[0];
if (htmlWidth >= 750) {
htmlDom.style.fontSize = '100px';
} else {
htmlDom.style.fontSize = htmlWidth / 3.75 + "px";
}
window.addEventListener("resize", function () {
var htmlDom = document.getElementsByTagName("html")[0];
var htmlWidth = document.documentElement.clientWidth || document.body.clientWidth
if (htmlWidth >= 750) {
htmlDom.style.fontSize = '100px';
} else {
htmlDom.style.fontSize = htmlWidth / 3.75 + "px";
}
});