什么是没有媒体类型的@media规则? [英] What's a @media rule without a media type do?

查看:116
本文介绍了什么是没有媒体类型的@media规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了这个,并且想知道没有媒体类型的媒体查询是什么?

  @media -width:768px){
.commentlist-item .commentlist-item {
padding:0 0 0 2em;
}
}

标准语法每www.w3schools.com/css/ css3_mediaqueries.asp

  @media not | only mediatype和(表达式){
CSS-Code;
}


解决方案

>如果媒体类型没有明确给出,它是 all 。 〜 W3C媒体查询


换句话说,没有媒体类型的@media规则是速记语法,其中 all



更多规格:


2。 Media
查询



提供适用于所有
媒体类型的媒体查询的简写语法;可以省略关键字 all (以及
结尾)。也就是说如果媒体类型没有明确给出,它是
all



示例5



这些都是相同的:

  @media all和(min-width:500px){...} 
@media (min-width:500px){...}

b
$ b

  @media(orientation:portrait){...} 
@media all和(orientation:portrait){...}

...



p>

这些是等效的:

  @media all {...} 
@media {...}

source: https://www.w3.org/TR/css3-mediaqueries/#media0



I inherited this and was wondering what does a media query without a "media type" do?

 @media (min-width: 768px) {
   .commentlist-item .commentlist-item {
    padding: 0 0 0 2em;
   }
}

Standard syntax per www.w3schools.com/css/css3_mediaqueries.asp

  @media not|only mediatype and (expressions) {
    CSS-Code;
}

解决方案

If the media type is not explicitly given it is all. ~ W3C Media Queries

In other words, an @media rule without a media type is shorthand syntax, where all is implied.

More from the spec:

2. Media Queries

A shorthand syntax is offered for media queries that apply to all media types; the keyword all can be left out (along with the trailing and). I.e. if the media type is not explicitly given it is all.

EXAMPLE 5

I.e. these are identical:

@media all and (min-width: 500px) { ... } 
@media (min-width: 500px) { ... }

As are these:

@media (orientation: portrait) { ... }
@media all and (orientation: portrait) { ... }

...

EXAMPLE 7

I.e. these are equivalent:

@media all { ... }
@media { ... }

source: https://www.w3.org/TR/css3-mediaqueries/#media0

这篇关于什么是没有媒体类型的@media规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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