<script type="text/javascript"> (function (doc, win) { // html var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function () { var clientWidth = docEl.clientWidth; if (!clientWidth) return; clientWidth = (clientWidth > 768 ) ? 768 : clientWidth ; docEl.style.fontSize = 10 * (clientWidth / 375 ) + 'px'; }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); recalc(); })(document, window); /*移动端适应大小*/ </script>
<div class="div-1"> ahahhhah </div>
.div-1{ width:250px; height:250px; background-color: red; font-size:1.6rem; }
直接粘贴运行
移动端rem文字自适式
最新推荐文章于 2021-06-03 02:00:50 发布