JS/CSS判断是不是iphoneX?

js判断

  if (/iphone/gi.test(navigator.userAgent) && (screen.height == 812 && screen.width == 375)) {
           //是iphoneX
   } else {
          //不是iphoneX
   }

CSS判断:

@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    .purchaseDiv, .closeBookList, .BottomProgress {
        bottom: 34px !important;
    }

}

猜你喜欢

转载自blog.csdn.net/wcy7916/article/details/83348192