1. 程式人生 > >@media 判斷iphone/ipad 各種機型

@media 判斷iphone/ipad 各種機型

相容iphone4/4s:

@media (device-height:480px) and (-webkit-min-device-pixel-ratio:2){ } 

相容iphone5 :

@media (device-height:568px) and (-webkit-min-device-pixel-ratio:2){ } 

相容iphone6,iphone7,iphone8s :

@media (device-height:667px) and (-webkit-min-device-pixel-ratio:2){ }

相容iphone6 Plus,iphone7 Plus,iphone8 Plus:

@media (device-height:736px) and (-webkit-min-device-pixel-ratio:2){ } 

相容iphoneX:

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

相容ipad :

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px){ /* style */ } 

相容ipad橫屏 :

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape){ /* style */ }

相容ipad豎屏 :

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait){ /* style */ }