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/40450228/

相关文章:

javascript - 如何创建全视口(viewport)屏幕网站布局

css - 字体系列和字体粗细 - 非常粗的粗体

javascript - 单击时的菜单项显示无

jquery - 在 IE 7 中滑动 rtl 和 ltr 的问题

jquery - 使用 JQuery 排列 Div

html - CSS 下拉菜单在 Chrome 中在按钮单击和悬停时向下滚动页面

html - 使 Bootstrap 轮播在不同设备上显示不同

browser - 如何使用 CSS 媒体查询检测设备方向?

html - 使用最大设备宽度调整大小时如何隐藏图像?

css - 在小型媒体查询菜单中未设置在中心它在中型或超小型中的工作