Can you nest @media and @support queries?
Publikováno: 5.8.2019
Yes, you can, and it doesn't really matter in what order. A CSS preprocessor is not required. It works in regular CSS.
This works:
@supports(--a: b) {
@media (min-width: 1px) {
body {
background: red;
}
}
}
And so does this, the reverse nesting of the above:
@media (min-width: 1px) {
@supports(--a: b) {
body {
background: green;
}
}
}
You can keep going with the nesting, if it ever makes sense:
@media (min-width: 2px) {
@media (min-width:
The post Can you nest @media and @support queries? appeared first on CSS-Tricks.
Yes, you can, and it doesn't really matter in what order. A CSS preprocessor is not required. It works in regular CSS.
This works:
@supports(--a: b) {
@media (min-width: 1px) {
body {
background: red;
}
}
}
And so does this, the reverse nesting of the above:
@media (min-width: 1px) {
@supports(--a: b) {
body {
background: green;
}
}
}
You can keep going with the nesting, if it ever makes sense:
@media (min-width: 2px) {
@media (min-width: 1px) {
@supports (--a: b) {
@supports (display: flex) {
body {
background: pink;
}
}
}
}
}
There is probably a point where the logic of that gets out of hand, so careful. But hey, it works. Presumably, you can "infinitely" nest at-rules.
The post Can you nest @media and @support queries? appeared first on CSS-Tricks.