REM+JS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>aaa</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,shrink-to-fit=no">
<style>
:root{font-size: 20px;}
</style>
</head>
<body>
TEST TEST TEST TEST TEST TEST TEST
<script>
let rootWidth = document.documentElement.clientWidth || document.body.clientWidth;
let rootDom = document.querySelector('html');
rootDom.style.fontSize = rootWidth / 10 + 'px';
</script>
</body>
</html>
VW模式:
vw单位是CSS3中的一个单位,代表屏幕横向尺寸的1%,用它做尺寸标准,可以完美适配缩放.
<style>
html{font-size: 5vw;}
</style>
<p style="font-size:0.8em">自适应大小</p>