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

前端 未结 1 1469
难免孤独
难免孤独 2020-12-17 21:29

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

 @media (min-width: 768px) {
   .commentlist-item .commentlist-item {         


        
相关标签:
1条回答
  • 2020-12-17 21:42

    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

    0 讨论(0)
提交回复
热议问题