如何使用>或<媒体查询中的(大于和小于)符号 [英] How to use > or < (Greater than and Less than ) Symbols in Media Queries

查看:382
本文介绍了如何使用>或<媒体查询中的(大于和小于)符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用>"或<"媒体查询中的符号(大于和小于)?例如,我想隐藏所有小于768px的显示器的潜水.我可以这样说吗?

Can we use the ">" or "<" symbols(Greater than and Less than ) in media queries? for example I would like to hide a dive for all monitors less than 768px. can I say some thing like this:

@media screen and (min-width<=768px) {}

推荐答案

媒体查询不使用这些符号.而是使用min-max-前缀. 规范:

Media queries don't make use of those symbols. Instead, they use the min- and max- prefixes. This is covered in the spec:

  • 大多数媒体功能都接受可选的"min-"或"max-"前缀,以表示大于或等于"约束和小于或等于"约束.该语法用于避免<".和>"字符,可能与HTML和XML冲突.那些接受前缀的媒体功能通常会与前缀一起使用,但也可以单独使用.
  • Most media features accept optional ‘min-’ or ‘max-’ prefixes to express "greater or equal to" and "smaller or equal to" constraints. This syntax is used to avoid "<" and ">" characters which may conflict with HTML and XML. Those media features that accept prefixes will most often be used with prefixes, but can also be used alone.

因此,您会说(max-width: 768px)而不是(width <= 768px)之类的东西:

So, instead of something like (width <= 768px), you would say (max-width: 768px) instead:

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

这篇关于如何使用&gt;或&lt;媒体查询中的(大于和小于)符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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