如果是iPhoneX等手机,底部有小黑条会遮挡底部的按钮
方法一:js判断, 给底部加padding适配。
$(document).ready(function () {
isIPhoneX();
function isIPhoneX() {
var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isIOS) {
if (screen.height == 812 && screen.width == 375) {
$('.menu_wkBox.back_box').css('padding-bottom', '0.5rem')
} else if (screen.height == 896 && screen.width == 414) {
$('.menu_wkBox.back_box').css('padding-bottom', '1rem')
}
}
}
});
// 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;
方法二:用css解决
meta:
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
css:
@supports (bottom: env(safe-area-inset-bottom)) {
.menu_wkBox.back_box{
padding-bottom: env(safe-area-inset-bottom);
}
}
参考:js判断iPhone XS、iPhone XS Max、iPhone XR,之后的几点思考总结 | 西门的后花园 http://ons.me/574.html