<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script> ;(function(doc,win,undefined){ const docEl = doc.documentElement; const resizeEvt = 'orientationchange' in win? 'orientationchange' : 'resize'; const recalc = function () { const clientWidth = docEl.clientWidth; if(clientWidth === undefined) return; docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';; }; if(doc.addEventListener === undefined) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); } )(document, window); </script> <style> *{ padding: 0; margin: 0; } html{ font-size: 62.5%;} body{ font-size: 16px;} .box{ 100%; background: red; height: 1rem; } .inner{ 13rem; height: 1rem; background-color: blue; } /* 设计图尺寸/85.375 * 85.375来源为 标准尺寸下的html font-size为16px ,但是经过计算后的font-size为85.375。故此值为这样来的。 */ .asdfasdf{ font-size: .2rem; } </style> </head> <body> <div class="box"> <div class="inner"> <div class="asdfasdf"> a </div> </div> </div> </body> </html>