|
1 | 1 | /**
|
2 | 2 | * CSS NESTING MODULES
|
| 3 | +* Review CSS nesting and non-nesting syntax For any issues. |
3 | 4 | */
|
4 | 5 |
|
5 | 6 | /*
|
6 |
| -- commas |
7 | 7 | - selectors
|
8 | 8 | - tag-names
|
9 | 9 | - combinators
|
10 | 10 | - functional-pseudo-classes
|
11 | 11 | - pseudo-classes
|
12 | 12 | - pseudo-elements
|
13 | 13 | - urls
|
14 |
| -- keyframes |
15 | 14 | - color-keywords
|
16 |
| -- at-rules |
17 |
| -- feature-query-operators |
18 |
| -- font-features |
19 | 15 | - functions
|
20 | 16 | - timing-function
|
21 | 17 | - keyword.operator.shape
|
22 | 18 | - property-names
|
23 | 19 | - property-values
|
24 | 20 | - property-keywords
|
25 | 21 | - string
|
26 |
| -- keyword.operator.comparison.css |
27 | 22 | */
|
| 23 | + |
| 24 | +/** |
| 25 | +* At Rules |
| 26 | +*/ |
| 27 | + |
| 28 | +@container (width > 400px) { |
| 29 | + h2 { |
| 30 | + font-size: 1.5em; |
| 31 | + } |
| 32 | + .card { |
| 33 | + width: 50%; |
| 34 | + background-color: gray; |
| 35 | + font-size: 1em; |
| 36 | + } |
| 37 | +} |
| 38 | +/* with an optional <container-name> */ |
| 39 | +@container tall (height > 30rem) { |
| 40 | + h2 { |
| 41 | + line-height: 1.6; |
| 42 | + } |
| 43 | +} |
| 44 | +.post { |
| 45 | + container-name: tall; |
| 46 | + container-type: inline-size; |
| 47 | +} |
| 48 | +/* shorthand syntax */ |
| 49 | +.post { |
| 50 | + container: tall / inline-size; |
| 51 | +} |
| 52 | + |
| 53 | +@counter-style thumbs { |
| 54 | + system: cyclic; |
| 55 | + symbols: "\1F44D"; |
| 56 | + suffix: " "; |
| 57 | +} |
| 58 | +ul { |
| 59 | + list-style: thumbs; |
| 60 | +} |
| 61 | + |
| 62 | +@font-face { |
| 63 | + font-family: "MyWebFont"; |
| 64 | + src: url("webfont.woff2") format("woff2"), url("webfont.woff") format("woff"); |
| 65 | +} |
| 66 | + |
| 67 | +@font-feature-values MyFont { |
| 68 | + @styleset { |
| 69 | + nice-style: 1; |
| 70 | + } |
| 71 | + @stylistic { |
| 72 | + nice-style: 1; |
| 73 | + } |
| 74 | + @character-variant { |
| 75 | + nice-style: 1; |
| 76 | + } |
| 77 | + @swash { |
| 78 | + nice-style: 1; |
| 79 | + } |
| 80 | + @ornaments { |
| 81 | + nice-style: 1; |
| 82 | + } |
| 83 | + @annotation { |
| 84 | + nice-style: 1; |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +@import url("https://fonts.googleapis.com/css?family=Open+Sans"); |
| 89 | + |
| 90 | +@keyframes slidein { |
| 91 | + from { |
| 92 | + margin-left: 100%; |
| 93 | + width: 300%; |
| 94 | + } |
| 95 | + to { |
| 96 | + margin-left: 0%; |
| 97 | + width: 100%; |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +@layer base { |
| 102 | + h1 { |
| 103 | + color: red; |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +@media (max-width: 600px) { |
| 108 | + .facet_sidebar { |
| 109 | + display: none; |
| 110 | + } |
| 111 | +} |
| 112 | +@media (min-width: 600px), (orientation: portrait) { |
| 113 | + /* Styles */ |
| 114 | +} |
| 115 | + |
| 116 | + |
| 117 | +@page { |
| 118 | + size: A4; |
| 119 | + margin: 10%; |
| 120 | +} |
| 121 | +@page :left { |
| 122 | + margin-top: 4in; |
| 123 | +} |
| 124 | +@page wide { |
| 125 | + size: a4 landscape; |
| 126 | +} |
| 127 | +@page { |
| 128 | + /* margin box at top right showing page number */ |
| 129 | + @top-right { |
| 130 | + content: "Page " counter(pageNumber); |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +/* @property is not cross-browsers friendly yet */ |
| 135 | +/* @property --my-color { |
| 136 | + syntax: '<color>'; |
| 137 | + inherits: false; |
| 138 | + initial-value: black; |
| 139 | +} */ |
| 140 | + |
| 141 | +/* @scope is not cross-browser friendly yet */ |
| 142 | +/* @scope (.article-body) to (figure) { |
| 143 | + img { |
| 144 | + border: 5px solid black; |
| 145 | + background-color: goldenrod; |
| 146 | + } |
| 147 | + :scope { |
| 148 | + background: rebeccapurple; |
| 149 | + color: antiquewhite; |
| 150 | + font-family: sans-serif; |
| 151 | + } |
| 152 | +} */ |
| 153 | + |
| 154 | +@supports (display: grid) { |
| 155 | + .grid { |
| 156 | + display: grid; |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | +/** |
| 161 | +* FEATURE QUERY OPERATORS (AND, OR, NOT) |
| 162 | +*/ |
| 163 | + |
| 164 | +/* AND */ |
| 165 | +@container (width > 400px) and (height > 400px) {} |
| 166 | +@media (min-width: 600px) and (orientation: landscape) {} |
| 167 | +@supports (display: grid) and (gap: 1rem) {} |
| 168 | + |
| 169 | +/* NOT */ |
| 170 | +@container not (width < 400px) {} |
| 171 | +@media not (orientation: landscape) {} |
| 172 | +@supports not (display: flex) {} |
| 173 | + |
| 174 | +/* OR */ |
| 175 | +@container (width > 400px) or (height > 400px) {} |
| 176 | +@supports (display: grid) or (display: flex) {} |
| 177 | + |
| 178 | +/** |
| 179 | +* COMBINATORS |
| 180 | +*/ |
| 181 | + |
| 182 | +.example > li { |
| 183 | + margin: 0; |
| 184 | +} |
| 185 | +div > span { |
| 186 | + margin: 0; |
| 187 | +} |
| 188 | +p ~ span { |
| 189 | + color: red; |
| 190 | +} |
| 191 | +img + p { |
| 192 | + color: red; |
| 193 | +} |
| 194 | + |
| 195 | +.example { |
| 196 | + div { |
| 197 | + > span { |
| 198 | + margin: 0; |
| 199 | + } |
| 200 | + } |
| 201 | + p { |
| 202 | + ~ span { |
| 203 | + color: red; |
| 204 | + } |
| 205 | + } |
| 206 | + img { |
| 207 | + + p { |
| 208 | + color: red; |
| 209 | + } |
| 210 | + } |
| 211 | +} |
| 212 | + |
| 213 | +.example { |
| 214 | + & div { |
| 215 | + & > span { |
| 216 | + margin: 0; |
| 217 | + } |
| 218 | + } |
| 219 | + & p { |
| 220 | + & ~ span { |
| 221 | + color: red; |
| 222 | + } |
| 223 | + } |
| 224 | + & img { |
| 225 | + & + p { |
| 226 | + color: red; |
| 227 | + } |
| 228 | + } |
| 229 | +} |
| 230 | + |
| 231 | +/** |
| 232 | +* COMMAS |
| 233 | +*/ |
| 234 | + |
| 235 | +body { |
| 236 | + figure:is(.class) { |
| 237 | + &.a, |
| 238 | + &.b { |
| 239 | + margin-block-end: 12px; |
| 240 | + } |
| 241 | + } |
| 242 | +} |
| 243 | + |
| 244 | +@media (prefers-reduced-motion: reduce) { |
| 245 | + html, |
| 246 | + html:focus-within { |
| 247 | + scroll-behavior: auto; |
| 248 | + } |
| 249 | +} |
| 250 | + |
| 251 | +.example { |
| 252 | + @media (min-width: 500px) { |
| 253 | + &::before, |
| 254 | + &::after { |
| 255 | + content: '"'; |
| 256 | + display: block; |
| 257 | + } |
| 258 | + } |
| 259 | +} |
| 260 | + |
| 261 | +@media only screen and (max-width: calc( (768 / 16) * 1rem )) { |
| 262 | + .class { |
| 263 | + fieldset, |
| 264 | + span { |
| 265 | + max-width: calc((768 / 16) * 1rem); |
| 266 | + flex: 0 0 100%; |
| 267 | + &.class_left, |
| 268 | + &.class_right { |
| 269 | + flex: 0 0 100%; |
| 270 | + } |
| 271 | + } |
| 272 | + } |
| 273 | +} |
| 274 | + |
| 275 | +/** |
| 276 | +* FUNCTIONS |
| 277 | +*/ |
| 278 | + |
| 279 | +.example { |
| 280 | + color: rgb(255, 0, 0); |
| 281 | + background-color: oklch(70% 0.1 315); |
| 282 | + margin: calc( (100 / 16) * 1rem); |
| 283 | + max-width: min(100%, 600px); |
| 284 | + padding: clamp(1rem, 5%, 2rem); |
| 285 | + width: calc(100% - 3em); |
| 286 | +} |
| 287 | + |
| 288 | +/** |
| 289 | + * PROPERTY NAMES WHEN SAME AS TAG NAMES |
| 290 | + */ |
| 291 | + |
| 292 | +.class::before { |
| 293 | + content: ""; |
| 294 | + cursor: pointer; |
| 295 | + filter: brightness(1.075); |
| 296 | +} |
| 297 | +content { |
| 298 | + margin: 0; |
| 299 | +} |
| 300 | +cursor { |
| 301 | + margin: 0; |
| 302 | +} |
| 303 | +filter { |
| 304 | + margin: 0; |
| 305 | +} |
| 306 | + |
| 307 | +/** |
| 308 | + * PSEUDO CLASS NESTING |
| 309 | + */ |
| 310 | + |
| 311 | +.class { |
| 312 | + > :nth-child(1) { |
| 313 | + margin: 0; |
| 314 | + } |
| 315 | + @media screen and (max-width: 1100px) { |
| 316 | + > :nth-child(1) { |
| 317 | + margin: 0; |
| 318 | + } |
| 319 | + } |
| 320 | +} |
| 321 | + |
| 322 | +/* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors */ |
| 323 | +/* https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes */ |
| 324 | +/* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_pseudo-elements */ |
| 325 | +/* https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements */ |
0 commit comments