Npcink Blog
切换菜单

CSS 判断 iphoneX、iphoneXs、iphoneXs Max、iphone XR - CSS 笔记

通过 CSS 判断 iphoneX、iphoneXs、iphoneXs Max、iphone XR 设备

iphoneX、iphoneXs、iphoneXs Max、iphone XR 都是 3 倍屏,宽度到是不大,但高是真高啊!

/* 兼容iphone6plus、iphone7plus、iphone8plus*/
@media (device-height:736px) and (-webkit-min-device-pixel-ratio:2){
}
/*iphoneX、iphoneXs*/
/*即: 设备屏幕可见宽度为375px, 可见高度为812px及设备像素比为3*/
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
}
/*iphone Xs Max*/
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio:3) {
}
/*iphone XR*/
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio:2) {
}