//iphoneX、iphoneXs

@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) {
}


js适配

  if(isiphonex()){
       alert('iphonex 机型')
}
function isiphonex() {
       // iPhone X、iPhone XS
       var isIPhoneX = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812;


       // iPhone XS Max
       var isIPhoneXSMax = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 414 && window.screen.height === 896;


       // iPhone XR
       var isIPhoneXR = /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 414 && window.screen.height === 896;

   if(isIPhoneX || isIPhoneXSMax || isIPhoneXR){
       return true;
   }
   }


今日吐槽

让烦恼与风去远行;让痛苦陪云去流浪。哼一曲好歌,也许心情,就会轻松许多

Contact ME

TAG Link