12345678910111213141516171819202122// 大屏自适应代码function scaleView() { var screenWidth = 1920; var screenHeight = 1080; var wScale = window.innerWidth / screenWidth; var hScale = window.innerHeight / screenHeight; var trueTop = (window.innerHeight - screenHeight * wScale) / 2; var trueLeft = (window.innerWidth - screenWidth * hScale) / 2; if (wScale >= hScale) { $(".mainBg").css({ transform: "scale(" + hScale + ")", top: 0, left: trueLeft, }); } else { $(".mainBg").css({ transform: "scale(" + wScale + ")", top: trueTop, left: 0, }); }}