function rendermeta(){ let width = document.documentelement.clientwidth; let scale = (width / 1300).tofixed(6); let height = document.body.scrollheight; if (width > 1300 || width < 768) { scale = 1; } if (scale < 1) { let marginleft = -390 * scale / 2; let margintop = -height * (1 - scale) / 2; //document.body.setattribute('style', 'transform:scale(' + scale + ');margin-left:' + (-marginleft) + 'px;margin-right:' + (-marginleft) + 'px;transform-origin:top;'); // document.body.setattribute('style', 'transform:scale(' + scale + ');margin:' + (-marginleft) + 'px;'); if (navigator.useragent.indexof('firefox') > -1) { //只有火狐有 // document.body.setattribute('style', 'transform:scale(' + scale + ');margin:' + margintop + 'px ' + marginleft + 'px;'); } else { document.body.setattribute('style', 'zoom:' + scale + ';'); } } else { //document.body.setattribute('style','margin-left:0;margin-right:0;margin-top:0;'); if (navigator.useragent.indexof('firefox') > -1) { //只有火狐有 // document.body.setattribute('style', 'margin-left:0;margin-right:0;margin-top:0;'); } else { document.body.setattribute('style', 'zoom:1;'); } } } $(window).resize(function(){ rendermeta() }) $(function(){ rendermeta() })