JS/CSS判断是否是retina屏幕

JS:

if(window.devicePixelRatio > 1){
    //是retina屏幕
}

 

CSS:

@media screen and (-webkit-min-device-pixel-ratio: 1.5),
screen and (-moz-min-device-pixel-ratio: 1.5) ,
screen and (-ms-min-device-pixel-ratio: 1.5) ,
screen and (-o-min-device-pixel-ratio: 1.5) ,
screen and (min-device-pixel-ratio: 1.5) {
    .test {
        /*是retina屏*/
    }
}

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注