運用CSS3媒體查詢判斷iPhoneX、iPhoneXR、iPhoneXS MAX及橫豎屏

//iphoneX、iphoneXsweb

@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
}iphone

即: 設備屏幕可見寬度爲375px, 可見高度爲812px及設備像素比爲3ip

 

//iphone Xs Max
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio:3) {
}it

 

//iphone XR
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio:2) {
}io

//橫屏webkit

@media all and (orientation : landscape) { di

vi

 

//豎屏像素

@media all and (orientation : portrait){ 

相關文章
相關標籤/搜索