css - 没有媒体类型的@media 规则是做什么的?

标签 css media-queries

我继承了这一点,想知道没有“媒体类型”的媒体查询有什么作用?

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

根据 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

换句话说,没有媒体类型的@media 规则是简写语法,其中隐含了all

更多来自规范:

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

关于css - 没有媒体类型的@media 规则是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35658627/

相关文章:

html - 格式化 CSS 表格和表单

javascript - 动态创建具有绝对位置的div,单击时可以扩展到整个屏幕

html - 是否有一些 CSS 参数可以应用于表格以使其用户无法单击它?

css - Vimeo 嵌入 CSS : override default text styles?

javascript - 更改 anchor 标记中引用的图像大小

html - 强元素有空格修复

html - 使用 CSS 从图像中删除 mime 类型图标,可能吗?

javascript - 调整所有媒体的文本大小

css - 不同屏幕宽度的不同样式表

html - 400px 的 CSS 媒体查询不起作用