当前位置: 首页 > Web前端 > HTML5

IphoneX底部贴合

时间:2023-04-05 01:48:47 HTML5

1.判断是否是IPhoneX手机letisIphone=/iphone/gi.test(window.navigator.userAgent)letwindowW=window.screen.widthletwindowH=window.screen.heightletpixelRatio=window.devicePixelRatioletisIPhoneX=isIphone&&pixelRatio&&pixelRatio===3&&windowW===375&&windowH===812letisIPhoneXSMax=isIphone&&pixelRatio&&pixelRatio===3&&windowW===414&&windowH===896letisIPhoneXR=isIphone&&pixelRatio&&pixelRatio===2&&windowW===414&&windowH===896if(isIPhoneX||isIPhoneXSMax||isIPhoneXR){//在底部添加fix-iphonex-bottm样式$(".contact-box").addClass('fix-iphonex-bottom')//在底部添加iphone-footer-bg样式initialnone,条件满足block$(".iphone-footer-bg").addClass('iphonexshow')}2.添加fix-iphonex-bottomstyle.fix-iphonex-bottom{bottom:34px!important;}想改变iPhoneX底部34px的背景色怎么办?3.添加iphone-footer-bgstyle.iphone-footer-bg{heig高:34px;背景:#6D6D6D;宽度:100%;位置:绝对;底部:-33px;显示:无;}.iphonexshow{显示:块!重要;}