欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

移动设备上的响应式设计:REM单位自适应的函数封装实践

最编程 2024-02-12 08:06:53
...
<script> (function () { var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'; var recalc = function () { var clientWidth = document.documentElement.clientWidth || document.body.clientWidth; if (!clientWidth) return document.documentElement.style.fontSize = clientWidth / 30 + 'px'; //根据你所在公司的具体情况灵活设置 document.documentElement.style.visibility = 'visible'; } if (!document.documentElement.addEventListener) { return; } window.addEventListener(resizeEvt, recalc, false); document.addEventListener('DOMContentLoaded', recalc, false); })(); //按需引入vConsole // var ua = window.navigator.userAgent.toLowerCase(); //var query_str = window.location.href; //if (query_str.indexOf('debug=true') > 0) { // document.writeln('<script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"' + '>' + '<' + '/' + 'script>'); // setTimeout(() => { // var vConsole = new VConsole(); //console.log('VConsole is cool'); // }, 500) // } </script>