1.在index.html中引入jq
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
2.写css
/* html{
overflow-x: hidden;
overflow-y: visible;
} */
body {
width: 1920px;
/* height: 1080px; */
/* background: url(../images/bg.png) 0% 0% / 100%; */
transform-origin: left top 0px;
overflow-y: visible;
-ms-transform-origin: left top 0px;
/* IE 9 */
-moz-transform-origin: left top 0px;
/* Firefox */
-webkit-transform-origin: left top 0px;
/* Safari 和 Chrome */
-o-transform-origin: left top 0px;
}
body::-webkit-scrollbar {
display: none;
}
3.写js
//等比例缩放屏幕
$(function(){
changeDivHeight();
})
//当浏览器窗口大小改变时,设置显示内容的高度
window.οnresize = function () {
changeDivHeight();
}
function changeDivHeight() {
// debugger;
var h = document.documentElement.clientWidth;//获取页面可见高度
var Bbodyhgt = h / 1920;
// $(document.body).css("-webkit-transform","scale(" + Bbodyhgt + ")");
// $(document.body).css({
// "-webkit-transform": "scale(" + Bbodyhgt + ")",
// "-ms-transform": "scale(" + Bbodyhgt + ")",
// "-moz-transform": "scale(" + Bbodyhgt + ")",
// "-o-transform": "scale(" + Bbodyhgt + ")",
// });
$("body").css({"zoom":Bbodyhgt});
}