<!doctype html>
<html lang="en" style="font-size: 37.5px;">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin:0;
padding:0;
}
#box{
width:4.24rem;
height:2.373rem;
margin-left:.56rem;
margin-top: 5.333rem;
background:#886;
}
</style>
</head>
<body>
<div id="box">
</div>
<script>
// 获取布局视口宽度
// var width = document.documentElement.clientWidth;
// var fontSize = width / 10;
// // 设置新的 font-size
// document.documentElement.style.fontSize = fontSize + ‘px‘
// 最终
window.onresize = function(){
// 设置新的 font-size
document.documentElement.style.fontSize = document.documentElement.clientWidth / 10 + ‘px‘
}
</script>
</body>
</html>
原文:https://www.cnblogs.com/eric-share/p/13759259.html