当前位置:网站首页>The mobile terminal page uses REM for adaptation

The mobile terminal page uses REM for adaptation

2022-06-11 09:17:00 WebCsDn_ TDCode

index.html Add this code

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'
}
   

according to UI 750 The proportion 100px = 1rem 

原网站

版权声明
本文为[WebCsDn_ TDCode]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110856546066.html