|
2 | 2 | * AT CONTAINER
|
3 | 3 | */
|
4 | 4 |
|
5 |
| -/* AND */ |
| 5 | +@container scroll-state(scrollable: none) {} |
| 6 | +@container scroll-state(scrollable: x) {} |
| 7 | +@container scroll-state(scrollable: y) {} |
| 8 | +@container scroll-state(scrollable: block) {} |
| 9 | +@container scroll-state(scrollable: inline) {} |
| 10 | +@container scroll-state(scrollable: top) {} |
| 11 | + |
| 12 | +/* MDN EXAMPLES */ |
| 13 | +/* With a <size-query> */ |
| 14 | +@container (width > 400px) { |
| 15 | + h2 { |
| 16 | + font-size: 1.5em; |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +/* With an optional <container-name> */ |
| 21 | +@container tall (height > 30rem) { |
| 22 | + p { |
| 23 | + line-height: 1.6; |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +/* With a <scroll-state> */ |
| 28 | +@container scroll-state(scrollable: top) { |
| 29 | + .back-to-top-link { |
| 30 | + visibility: visible; |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +/* With a <container-name> and a <scroll-state> */ |
| 35 | +@container sticky-heading scroll-state(stuck: top) { |
| 36 | + h2 { |
| 37 | + background: purple; |
| 38 | + color: white; |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +@container my-container scroll-state(scrollable: top) { |
| 43 | + /* CSS rules go here */ |
| 44 | +} |
| 45 | + |
| 46 | +.container { |
| 47 | + container-type: scroll-state; |
| 48 | + container-name: my-container; |
| 49 | +} |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +@container not scroll-state(scrollable: none) { |
| 54 | + /* … */ |
| 55 | +} |
| 56 | + |
| 57 | + |
| 58 | +/* Multiple queries in a single condition */ |
| 59 | +@container (width > 400px) and style(--responsive: true) { |
| 60 | + h2 { |
| 61 | + font-size: 1.5em; |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +/* Condition list */ |
| 66 | +@container card (width > 400px), style(--responsive: true), scroll-state(stuck: top) { |
| 67 | + h2 { |
| 68 | + font-size: 1.5em; |
| 69 | + } |
| 70 | +} |
| 71 | + |
6 | 72 | @container (width > 400px) and (height > 400px) {
|
| 73 | + /* <stylesheet> */ |
| 74 | +} |
| 75 | + |
| 76 | +@container (width > 400px) or (height > 400px) { |
| 77 | + /* <stylesheet> */ |
| 78 | +} |
| 79 | + |
| 80 | +@container not (width < 400px) { |
| 81 | + /* <stylesheet> */ |
| 82 | +} |
| 83 | + |
| 84 | +.post { |
| 85 | + container-name: sidebar; |
| 86 | + container-type: inline-size; |
| 87 | +} |
| 88 | +.post { |
| 89 | + container: sidebar / inline-size; |
| 90 | +} |
| 91 | + |
| 92 | +@container (min-width: 400px) { |
| 93 | + /* … */ |
| 94 | +} |
| 95 | +@container (orientation: landscape) and (width > 400px) { |
| 96 | + /* … */ |
| 97 | +} |
| 98 | +@container (15em <= block-size <= 30em) { |
| 99 | + /* … */ |
7 | 100 | }
|
| 101 | + |
| 102 | +@container scroll-state(scrollable: top) { |
| 103 | + /* … */ |
| 104 | +} |
| 105 | +@container scroll-state(stuck: inline-end) { |
| 106 | + /* … */ |
| 107 | +} |
| 108 | +@container scroll-state(snapped: both /*comment*/) { |
| 109 | + /* … */ |
| 110 | +} |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +/* AND */ |
| 117 | +@container/*comment*/ (width > 400px) and (height > 400px) { |
| 118 | +} |
| 119 | + |
8 | 120 | @container (min-width: 600px) and (orientation: landscape) {
|
9 | 121 | }
|
10 | 122 |
|
|
13 | 125 | }
|
14 | 126 | @container not (width < 400px) not (width > 800px) {
|
15 | 127 | }
|
16 |
| -@container sidebar not (orientation: landscape) and (min-width: 600px) { |
| 128 | +@container/*comment*/sidebar not /*comment*/ (orientation: landscape/*comment*/) and /*comment*/ (/*comment*/min-width: 600px) /*comment*/ { |
| 129 | +} |
| 130 | +@container /*comment*/sidebar not (orientation:landscape) and (min-width: 600px) { |
17 | 131 | }
|
18 | 132 | @container sidebar not (orientation: landscape) and (min-width: 600px) or (min-width: 600px) {
|
19 | 133 | }
|
20 | 134 |
|
21 | 135 | /* OR */
|
22 |
| -@container (width > 400px) or (height > 400px) {'' |
23 |
| -} |
24 |
| -@container (display: grid) or (display: flex) { |
25 |
| -} |
| 136 | +@container (width > 400px) or (height > 400px) { |
| 137 | +}@container test (width > 400px) or (height > 400px) |
| 138 | +{} |
26 | 139 |
|
27 | 140 | /* CONTAINER-NAME */
|
28 | 141 | @container name (width > 400px) and (height > 400px) {
|
29 | 142 | }
|
30 |
| -@container name1 name2 name3 not (width > 400px) not (height > 400px) { |
| 143 | +@container name1 not (width > 400px) not (height > 400px) { |
| 144 | +} |
| 145 | +@container name1 name_2 name-3 not (width > 400px) not (height > 400px) { |
31 | 146 | }
|
32 | 147 |
|
33 | 148 | @container default (width > 400px) {
|
|
0 commit comments