适配iPhone X系列底部导航

window.screen.height/window.innerHeight = window.screen.width/window.innerWidth

100%



window.screen.height - window.innerHeight / scale < 100

// 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;

 let isIphone = /iphone/gi.test(window.navigator.userAgent);
 let windowW = window.screen.width;
 let windowH = window.screen.height;
 let pixelRatio = window.devicePixelRatio;
 function cd_check() {//适配iPhone 机型方法
     let isIPhoneX = isIphone && pixelRatio && pixelRatio === 3 && windowW === 375 && windowH === 812;
     let isIPhoneXSMax = isIphone && pixelRatio && pixelRatio === 3 && windowW === 414 && windowH === 896;
     let isIPhoneXR = isIphone && pixelRatio && pixelRatio === 2 && windowW === 414 && windowH === 896;
     var scale = window.innerWidth / window.screen.width;
     console.log(window.screen.height, window.innerHeight, scale);
     if(platType!= "miniprogram"){
      if (window.screen.height - window.innerHeight / scale < 100) {//没有微信菜单
             if (isIPhoneX || isIPhoneXSMax || isIPhoneXR) {
                 // 底部增加fix-iphonex-bottm 样式
                 $(".navbottom-box").addClass('fix-iphonex-bottom');
                 $(".dcsec1").addClass('fix-iphonex-cd_se');
             }
         } else {
             if (isIPhoneX || isIPhoneXSMax || isIPhoneXR) {//有微信菜单
                 // 底部增加fix-iphonex-bottm 样式
                 $(".navbottom-box").removeClass('fix-iphonex-bottom');
                 $(".dcsec1").removeClass('fix-iphonex-cd_se');
             }
         }
  }else{
  var x=(windowW === 375 && windowH === 724 && isIphone);
  /* iPhone XS Max */
  var xsMax=(windowW === 414 && windowH === 808 && isIphone);
  var xi=(windowW === 375 && windowH === 812 && isIphone);
  /* iPhone XR */
  var xR=(windowW === 414 &&windowH === 896 && isIphone);
  if (x || xsMax || xR ||xi) {
             // 底部增加fix-iphonex-bottm 样式
             $(".navbottom-box").addClass('fix-iphonex-bottom');
             $(".dcsec1").addClass('fix-iphonex-cd_se');
             $(".hyNav-box").addClass('fix-iphonex-bottom1');
             //$("#allsy").addClass('fix-iphonex-cd1');
             /*$(".bigFloor").addClass('fix-iphonex-cd1');
             $(".scMy_btn").css("height","1.92rem");
             //$(".scMy_btn").css("padding-bottom ","34px !important");
             $("#lableList").css("height","84%");*/
         }
  }
     
 }
 //页面加载先调用一次
 cd_check();
 $(window).scroll(function () {//监听页面滑动每次滑动重新调用
  cd_check();
 })

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值