Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
724 views
in Technique[技术] by (71.8m points)

css - What's a @media rule without a media type do?

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;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...