@@ -466,11 +466,12 @@ Nesting Conditional Rules {#conditionals}
466
466
-----------------------------------------------
467
467
468
468
A style rule can have any number of <a>conditional rules</a> inside of it, of any type,
469
- intermixed with any number of declarations, in any order .
469
+ with rules required to come after declarations (see <a href="#mixing">Mixing Nesting Rules and Declarations</a> ) .
470
470
471
- The presence of a nested conditional engages the same logic as if ''@nest'' was present.
472
- The nested conditional rules must contain a <a>nesting selector</a> and follow the same
473
- rules as outlined in <a href="#direct">direct nesting</a> .
471
+ If there are only declarations in the nested conditional, the nesting context is adopted.
472
+
473
+ In the presence of a <a>nesting selector</a> , the same
474
+ rules as outlined in <a href="#direct">direct nesting</a> should be used.
474
475
475
476
<div class="example">
476
477
For example, the following conditional nestings are valid:
@@ -480,14 +481,22 @@ Nesting Conditional Rules {#conditionals}
480
481
display: grid;
481
482
482
483
@media (orientation: landscape) {
483
- & {
484
- grid-auto-flow: column;
485
- }
484
+ grid-auto-flow: column;
486
485
}
487
486
}
488
487
/* equivalent to
489
488
.foo { display: grid; }
490
489
490
+ @media (orientation: landscape) {
491
+ & {
492
+ grid-auto-flow: column;
493
+ }
494
+ }
495
+ */
496
+
497
+ /* finally equivalent to
498
+ .foo { display: grid; }
499
+
491
500
@media (orientation: landscape) {
492
501
.foo {
493
502
grid-auto-flow: column;
@@ -499,14 +508,10 @@ Nesting Conditional Rules {#conditionals}
499
508
display: grid;
500
509
501
510
@media (orientation: landscape) {
502
- & {
503
- grid-auto-flow: column;
504
- }
511
+ grid-auto-flow: column;
505
512
506
513
@media (min-inline-size > 1024px) {
507
- & {
508
- max-inline-size: 1024px;
509
- }
514
+ max-inline-size: 1024px;
510
515
}
511
516
}
512
517
}
@@ -551,15 +556,6 @@ Nesting Conditional Rules {#conditionals}
551
556
But the following are invalid:
552
557
553
558
<pre class=lang-css>
554
- .foo {
555
- display: grid;
556
-
557
- @media (orientation: landscape) {
558
- grid-auto-flow: column;
559
- }
560
- }
561
- /* Invalid because there's no nesting selector */
562
-
563
559
.foo {
564
560
color: red;
565
561
@@ -800,4 +796,4 @@ return the result of the following steps:
800
796
</ol>
801
797
<li> Append a newline followed by RIGHT CURLY BRACKET (U+007D) to |s|.
802
798
<li> Return |s|.
803
- </ol>
799
+ </ol>
0 commit comments