モバイル デバイスのディスプレイと同様に、高解像度ディスプレイでは、小さなサイズの画面での高解像度によるピクセル密度の高さが原因で、常にぼやけた効果が生じます。
これを修正する回避策があります。
このトリックを使用すると、高解像度ディスプレイで画像を拡大または表示するときに、画像がぼやけなくなります。
コメントで要求されているように、背景サイズをズームに適応させるコードは次のとおりです。
ジャバスクリプト:
if (window.addEventListener){
window.addEventListener('resize', setBackground, false);
} else {
window.attachEvent('onresize', setBackground);
}
function setBackground(){
document.body.style.backgroundSize =
(((( window.screen.width / ( window.screen.width / getImageWidth() )) / 10) > 1 ) ? (( window.screen.width / ( window.screen.width / getImageWidth() )) / 10) : 1) + "%";
}
function getImageWidth(){
var imageSrc = document
.body
.style
.backgroundImage
.replace(/url\((['"])(.*?)\1\)/gi, '$2')
.split(',')[0];
var image = new Image();
image.src = imageSrc;
var width = image.width;
return width;
}
HTML:
<body onLoad="javascript:setBackground();" style="background: url(bkg.jpg) repeat;">