In CSS Cascading & Inheritance L5 we define the @layer
rule, and the way layers "stack" in priority based on the order they are first encountered. These will stack so the higher numbers override the lower numbers:
@layer one; @layer two; @layer three;
In general, layers should interact well with conditional rules. In isolation these two rules should mean the same thing:
@layer one { @media (width > 500px) { /* styles */ } } @media (width > 500px) { @layer one { /* styles */ } }
If the media-condition is true, then the styles are applied in the specified layer (one
). But it's a bit less clear how the second example (layer inside condition) should impact the order of multiple layers:
@media (width > 500px) { @layer one { /* styles */ } } @layer two; @layer three; @layer one;
Does layer one
come first, last, or does it update dynamically based on the evaluation of the condition? I think the two options are roughly:
This question is also relevant to other conditions, such as @supports
or @container
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5