iphone/ipad media query issues

心不动则不痛 提交于 2019-12-23 04:14:05

问题


I had a concern. I'm putting together a little site and for some reason my iphone and ipad media queries are colliding. The Iphone picks up on Ipad styles, but not vice versa. So I wanted to put what I'm using out there and see if anyone can help.

thanks guys.

@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) //iphone
@media screen and (max-device-width: 480px) and (orientation:landscape) //iphone landscape
@media screen and (max-device-width: 1024px) and (orientation:landscape) //ipad landscape
@media screen and (max-device-width: 768px) and (orientation:portrait) //ipad portrait

I pulled these from a few tutorials that seemed pretty legit, any ideas why the styles are leaking?


回答1:


You're using max-device-width which will include iphone as well. Should be:

@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2) //iphone
@media screen and (max-device-width: 480px) and (orientation:landscape) //iphone landscape
@media screen and (min-device-width: 1024px) and (orientation:landscape) //ipad landscape
@media screen and (min-device-width: 768px) and (orientation:portrait) //ipad portrait

notice the min-device-width



来源:https://stackoverflow.com/questions/8910777/iphone-ipad-media-query-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!