当前位置:网站首页>移动端页面使用rem来做适配

移动端页面使用rem来做适配

2022-06-11 08:57:00 WebCsDn_TDCode

index.html添加此代码

fnResize()
        window.onresize = function() {
            fnResize()
        }

        function fnResize() {
            var deviceWidth = document.documentElement.clientWidth || window.innerWidth
            if (deviceWidth >= 750) {
                deviceWidth = 750
            }
            if (deviceWidth <= 320) {
                deviceWidth = 320
        }
        document.documentElement.style.fontSize = (deviceWidth / 7.5) + 'px'
}
   

按照UI 750比例 100px = 1rem 

原网站

版权声明
本文为[WebCsDn_TDCode]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42396791/article/details/125173988