直接干货
iphoneX()
function iphoneX() {
var userAgent = navigator.userAgent
var ios = !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) //ios终端
if (ios) {
if (screen.height == 812 && screen.width == 375) {
$('.footer').css('padding-bottom', '0.5rem')
} else if (screen.height == 896 && screen.width == 414) {
$('.footer').css('padding-bottom', '1rem')
}
}
}
// iPhone X、iPhone XS
let isIPhoneX =
/iphone/gi.test(window.navigator.userAgent) &&
window.devicePixelRatio &&
window.devicePixelRatio === 3 &&
window.screen.width === 375 &&
window.screen.height === 812
// iPhone XS Max
let isIPhoneXSMax =
/iphone/gi.test(window.navigator.userAgent) &&
window.devicePixelRatio &&
window.devicePixelRatio === 3 &&
window.screen.width === 414 &&
window.screen.height === 896
// iPhone XR
let isIPhoneXR =
/iphone/gi.test(window.navigator.userAgent) &&
window.devicePixelRatio &&
window.devicePixelRatio === 2 &&
window.screen.width === 414 &&
window.screen.height === 896
网友评论