微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

组合CSS媒体查询

我想为打印页面(media = print)的人和在手机上浏览的人显示相同的CSS样式集。有没有办法我可以结合CSS媒体查询

就像是

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

     #container {
         width: 480px;
     }
}

解决方法

用逗号分隔它们:
@media only print,only screen and (max-device-width: 480px)

See the spec,特别是实施例VI(加重部分):

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 only print,screen and (max-device-width: 480px)

原文地址:https://www.jb51.cc/css/222031.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。