简体   繁体   English

CSS媒体查询:最大宽度和最大高度

[英]CSS media queries: max-width And max-height

I want to use AND condition in media query. 我想在媒体查询中使用AND条件。 I use the the following code, but it didn't works 我使用以下代码,但是没有用

@media screen and (max-width: 995px AND max-height: 700px) {
}

逻辑运算符前后缺少右括号和右括号

@media (max-width: 995px) and (max-height: 700px) { ... }

The correct and simpliest way to write this is: 正确且最简单的书写方式是:

@media screen and (max-width: 995px) and (max-height: 700px) {

}

Use a comma to specify two (or more) different rules: 使用逗号指定两个(或多个)不同的规则:

@media screen and (max-width: 995px) , screen and (max-height: 700px) {
 ...
}

From https://developer.mozilla.org/en/CSS/Media_queries/ https://developer.mozilla.org/en/CSS/Media_queries/

...In addition, you can combine multiple media queries in a comma-separated list; ...此外,您可以在逗号分隔的列表中组合多个媒体查询; if any of the media queries in the list is true, the associated style sheet is applied. 如果列表中的任何媒体查询为true,则将应用关联的样式表。 This is the equivalent of a logical "or" operation. 这等效于逻辑“或”运算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM