Skip to content

Commit ab9873e

Browse files
committed
[css-nesting-1] add @scope and @layer examples
1 parent 6b7d920 commit ab9873e

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

css-nesting-1/Overview.bs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,81 @@ Syntax {#syntax}
427427
figure > figcaption { background: hsl(0 0% 0% / 50%); }
428428
figure > figcaption > p { font-size: .9rem; }
429429
*/
430+
431+
<b>/* Example usage with Cascade Layers */</b>
432+
@layer base {
433+
html {
434+
block-size: 100%;
435+
436+
& body {
437+
min-block-size: 100%;
438+
}
439+
}
440+
}
441+
/* equivalent to
442+
@layer base {
443+
html { block-size: 100%; }
444+
html body { min-block-size: 100%; }
445+
}
446+
*/
447+
448+
<b>/* Example nesting Cascade Layers */</b>
449+
@layer base {
450+
html {
451+
block-size: 100%;
452+
453+
@layer base.support {
454+
& body {
455+
min-block-size: 100%;
456+
}
457+
}
458+
}
459+
}
460+
/* equivalent to
461+
@layer base {
462+
html { block-size: 100%; }
463+
}
464+
@layer base.support {
465+
html body { min-block-size: 100%; }
466+
}
467+
*/
468+
469+
<b>/* Example usage with Scoping */</b>
470+
@scope (.card) to (> header) { {
471+
:scope {
472+
inline-size: 40ch;
473+
aspect-ratio: 3/4;
474+
475+
> header {
476+
border-block-end: 1px solid white;
477+
}
478+
}
479+
}
480+
/* equivalent to
481+
@scope (.card) to (> header) {
482+
:scope { inline-size: 40ch; aspect-ratio: 3/4; }
483+
:scope > header { border-block-end: 1px solid white; }
484+
}
485+
*/
486+
487+
<b>/* Example nesting Scoping */</b>
488+
.card {
489+
inline-size: 40ch;
490+
aspect-ratio: 3/4;
491+
492+
@scope (&) to (> header > *) {
493+
:scope > header {
494+
border-block-end: 1px solid white;
495+
}
496+
}
497+
}
498+
499+
/* equivalent to
500+
.card { inline-size: 40ch; aspect-ratio: 3/4; }
501+
@scope (.card) to (> header > *) {
502+
:scope > header { border-block-end: 1px solid white; }
503+
}
504+
*/
430505
</pre>
431506

432507
But these are not valid:

0 commit comments

Comments
 (0)