リファレンス:https://www.cnblogs.com/LiuWeiLong/p/6058059.html
今日、win10コンピューターでズームが行われている可能性があることがわかりました。120pxの画像とCSS設定の120pxを切り取る際に問題がありますが、Webページの表示には120 * 1.25 pxと表示されます。
/ * * *グローバルページズームを動的に変更して、切り取りと表示が異なるのを防ぎます * / window.onresize = function (e){ detectZoom(); } function detectZoom(){ var ratio = 0 、 screen = window.screen、 ua = navigator.userAgent.toLowerCase(); if(window.devicePixelRatio!== undefined){ ratio = window.devicePixelRatio; } else if(〜ua.indexOf( 'msie' )){ if(screen.deviceXDPI &&screen.logicalXDPI){ ratio = screen.deviceXDPI / screen.logicalXDPI; } } else if(window.outerWidth!== undefined && window.innerWidth!== undefined){ ratio = window.outerWidth / window.innerWidth; } if (比率){ 比率 = Math.round(比率* 100 ); } // 比率を返す; document.querySelector( "html")。style.fontSize =(16 /(ratio / 100))+ "px" ; }