判断屏幕是否过大 或国小 进行 缩放达到自适应

     function scalScreen() {
            let docEl = document.documentElement;
            let scale = $(window).width() / 1920;
            let _width, _height;
            window.clientWidth = docEl.clientWidth;
            window.clientHeight = docEl.clientHeight;
            console.log(window.clientWidth)
            if (scale < 1) {
                _width = -(1920 - (1920 * scale)) / 2 + 'px';
                _height = -(1080 - (1080 * scale)) / 2 + 'px';
            } else {
                _width = ((1920 * scale) - 1920) / 2 + 'px';
                _height = ((1080 * scale) - 1080) / 2 + 'px';
            }

            $('#special_detail_index').css({
            'transform':'translate('+_width+','+_height+') scale('+scale+')'
            })
        }

         $(window).resize(function () {scalScreen();console.log(111)})
        scalScreen()
原文地址:https://www.cnblogs.com/lvlisn/p/15556388.html