如何从打印隐藏CSS媒体查询? “不是"逻辑运算符不起作用 [英] How to hide a CSS media query from print? "not" logical operator does not work

查看:75
本文介绍了如何从打印隐藏CSS媒体查询? “不是"逻辑运算符不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图隐藏媒体查询,使其不被打印,所以我想出了@media not print and (min-width:732px).但是无论出于何种原因,它(以及我尝试过的许多变体)都无法像我期望的那样在浏览器中显示.

I am trying to hide a media query from being printed, so I came up with @media not print and (min-width:732px). But for whatever reason, this (and many variations I have tried) does not display as I would expect in browsers.

我唯一想到的选择是使用@media screen and (max-width:732px),但是我想避免这种情况,因为它排除了屏幕以外的所有其他媒体类型.

The only option I can think of is to use @media screen and (max-width:732px), but I would like to avoid this as it excludes all the other media types besides screen.

推荐答案

这样的事情怎么样?

body { min-width:732px; }
@media print {
   body { min-width:initial; }
}

所有内容的最小宽度都将设置为732,但print除外,它将获得您指定的其他值.根据您的情况,您可以设置其他宽度,或者尝试使用"thiswontwork"(有时会导致将值设置为初始值)或"inherit"之类的东西.

The min-width will be set to 732 for everything, except print, which will get some other value that you specify. Depending on your situation, you can set a different width, or try something like "thiswontwork" (which sometimes causes the value to be set to the initial value) or "inherit" or something like that.

这篇关于如何从打印隐藏CSS媒体查询? “不是"逻辑运算符不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆