Can I use “OR” in a CSS media query?

做~自己de王妃 提交于 2019-12-02 05:33:25

问题


I'm trying to combine the following three media queries into one:

@media only screen and (max-device-width: 480px) {
}

@media only screen and (-webkit-min-device-pixel-ratio: 2) {
}

@media only screen and (max-device-width: 1024px) {
}

I've tried this below, but it doesn't work:

@media only screen and (max-device-width: 480px),
@media only screen and (-webkit-min-device-pixel-ratio: 2),
@media only screen and (max-device-width: 1024px) {
}

Is there a way to combine these, possibly with an "OR"?


回答1:


From the specification

Here is an example of several media queries in a comma-separated list using the an @media-rule in CSS: @media screen and (color), projection and (color) { … }

Only use @media at the start of the rule.



来源:https://stackoverflow.com/questions/6640353/can-i-use-or-in-a-css-media-query

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