JS:
$(document).ready(function () {
document.body.style.transform = "scale(" + (window.innerWidth) / (window.outerWidth) + ")";
document.body.style.width = 100 * (window.outerWidth) / (window.innerWidth) + "%";
});
$(window).resize(function () {
document.body.style.transform = "scale(" + (window.innerWidth) / (window.outerWidth) + ")";
document.body.style.width = 100 * (window.outerWidth) / (window.innerWidth) + "%";
});
CSS:
body{
transform-origin:0 0;
position:absolute;
top:0;
left:0;
right:0;
margin:0;
padding:0;
}
身体:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
body body body body...
更新:
如果您的网页内容在左侧,请使用 transform-origin: 0 0; 如果它在正确的使用 transform-origin: 100% 0; 如果它在中心使用 transform-origin: center 0; 如果您在几个地方有内容或从左/顶部有 x 像素,而不是单独缩放身体缩放每个 div 并将变换原点适合它的位置,而不是像这样调整它的宽度和高度:
document.getElementById("id").style.width = document.getElementById("id").style.width * (window.outerWidth) / (window.innerWidth) + "px";
document.getElementById("id").style.height = document.getElementById("id").style.height * (window.outerWidth) / (window.innerWidth) + "px";