| 1 |
// Media queries can be nested within one another. The intersection of the two |
| 2 |
// queries will be generated. |
| 3 |
@media screen { |
| 4 |
a {b: c} |
| 5 |
@media (color) {x {y: z}} |
| 6 |
} |
| 7 |
|
| 8 |
// Features always go to the end of a query, even if they're at an outer nesting |
| 9 |
// level. |
| 10 |
@media (color) { |
| 11 |
a {b: c} |
| 12 |
@media screen {x {y: z}} |
| 13 |
} |
| 14 |
|
| 15 |
// Different features can be intersected. |
| 16 |
@media (max-width: 300px) { |
| 17 |
a {b: c} |
| 18 |
@media (min-width: 200px) {x {y: z}} |
| 19 |
} |
| 20 |
|
| 21 |
// Different media types *can't* be intersected, so they're eliminated. |
| 22 |
@media screen { |
| 23 |
a {b: c} |
| 24 |
@media print {x {y: z}} |
| 25 |
} |
| 26 |
|
| 27 |
// Likewise, there's no way to generate the intersection of these queries. We |
| 28 |
// could write `not screen and (color)`, but that actually means "neither |
| 29 |
// `screen` nor `(color)`" rather than "not `screen` but yes `(color)`. |
| 30 |
// |
| 31 |
// The latest spec allows us to generate `not screen and not (color)` here, |
| 32 |
// which would work, but no browsers support it yet. |
| 33 |
@media not screen { |
| 34 |
a {b: c} |
| 35 |
@media (color) {x {y: z}} |
| 36 |
} |
| 37 |
|
| 38 |
// The intersection of `not screen` and `print` is just `print`. |
| 39 |
@media not screen { |
| 40 |
a {b: c} |
| 41 |
@media print {x {y: z}} |
| 42 |
} |
| 43 |
@media print { |
| 44 |
a {b: c} |
| 45 |
@media not screen {x {y: z}} |
| 46 |
} |
| 47 |
|
| 48 |
/// The intersection of `not screen` and `screen` is empty. |
| 49 |
@media not screen { |
| 50 |
a {b: c} |
| 51 |
@media screen {x {y: z}} |
| 52 |
} |
| 53 |
@media screen { |
| 54 |
a {b: c} |
| 55 |
@media not screen {x {y: z}} |
| 56 |
} |
| 57 |
|
| 58 |
// Unlike `not`, the `only` keyword is preserved through intersection. |
| 59 |
@media only screen { |
| 60 |
a {b: c} |
| 61 |
@media (color) {x {y: z}} |
| 62 |
} |