最小/最大宽度媒体查询不使语法意义 [英] The min/max-width media query doesn't make grammatical sense

查看:642
本文介绍了最小/最大宽度媒体查询不使语法意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现(min-width / max-width)媒体查询的概念有点混乱。

I'm finding the concept of the (min-width/max-width) media query a bit confusing.

当然,如果我设计一个媒体查询我想说(在伪代码中)....

Naturally if I was to design a media query I would want to say (in pseudo-code)....

if(screen.width < 420)
{
     ApplyStyle();
}

这个讨论min和max的概念没有任何意义,因为

This concept of talking about min and max doesn't make any sense since the 'min-width' of something like a div element is a command not a question.

我知道当我的屏幕低于420像素时,以下是真的...

I know that the following is true when my screen goes below 420px...

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


}

我只是不知道为什么,因为最大宽度是我告诉它。如果我告诉它有一些东西为什么是CSS检查它?当然它已经知道了。

I just don't know why because the max width is something I tell it to have. If I have told it to have something why is css checking it? Surely it already knows it.

我可能在这里缺少语法/语境。有人可以解释吗?

I'm perhaps missing the grammer/context here. Can someone please explain?

推荐答案

min-width 与元素上设置的 min-width 属性无关,这是两个不同的东西。

min-width in media queries is not related to the min-width property you set on elements, those are two different things.

min-width:X 如果视口的宽度大于或等于X,则为true,有效地工作为 screen.width> = X 。显然 max-width 会等于 screen.width< = X

In media queries min-width: X is true if the viewport has a width greater or equal to X, effectively working as screen.width >= X. Obviously max-width would then be equal to screen.width <= X

对我来说,如果你看到 @media屏幕和(max-width:420px)作为屏幕最大宽度为420px ,所以从0到420px的任何东西

To me it makes perfect sense, if you read @media screen and (max-width:420px) as a screen with a maximum width of 420px, so anything from 0 to 420px

这篇关于最小/最大宽度媒体查询不使语法意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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