android - 如何创建适用于设备宽度和宽度的媒体查询

标签 android css media-queries responsive-design

当我调整页面大小时,我尝试让这个媒体查询在桌面和手机上都有效。

这在移动设备上工作

@media screen and (max-device-width: 320px) {
   ...
}

这是在桌面上

@media screen and (max-width: 320px) {
   ...
}

但我无法让它们工作 我尝试使用 运算符但没有工作。

最佳答案

根据W3 documentation for Media Queries :

Several media queries can be combined in a media query list. A comma-separated list of media queries. If one or more of the media queries in the comma-separated list are true, the whole list is true, and otherwise false. In the media queries syntax, the comma expresses a logical OR, while the ‘and’ keyword expresses a logical AND.

使用逗号代替:

@media screen and (max-device-width: 320px), (max-width: 320px) {
   ...
}

关于android - 如何创建适用于设备宽度和宽度的媒体查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10953242/

相关文章:

Android:在推送通知时更新堆栈上的 Activity

css - 垂直渐变

html - 如何使该Flex Box成为整个屏幕的宽度?

css - 如何定位带触摸屏/无鼠标的设备?

html - 修复了运行 CSS3 的打印标题

java - 更改 RecyclerView 项目时刷新 SearchView

android - 背景 xml 不工作

android - 连接WIFI时获取SSID

css - 在 IE11 中无法使用分词符将单词分成几行

css - 在响应式媒体查询中使用 cm?