Media queries - targeting specific devices together

强颜欢笑 提交于 2019-12-12 00:39:07

问题


I've got a devices stylesheet that is loaded to deal with responsive design in a website, but I'm struggling to group a couple different media queries exactly how I want.

I've got a shared set of styles for a small web window, a mobile device at any rotation and an iPad in portrait only.

At the moment I'm getting everything except the iPad with this query:

@media all and (max-device-width: 480px), all and (max-width: 480px)

I'm getting the iPad in portrait with this code:

@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait)

How do I combine these two media queries?


回答1:


Okay, for anyone with this problem.

To achieve this I ended up using the media queries to load the stylesheet, rather than embedding the media query in my stylesheet.

<link rel="stylesheet" type="text/css" media="all and (max-device-width: 480px), all and (max-width: 480px)" href="device.css" />
<link rel="stylesheet" type="text/css" media="@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait)" href="device.css" />


来源:https://stackoverflow.com/questions/16392429/media-queries-targeting-specific-devices-together

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