-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.css
464 lines (372 loc) · 9.81 KB
/
base.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
/* Document
======================================== */
/**
* 1. Use border box sizing by default, globally (opinionated).
* 2. Backgrounds do not repeat by default (opinionated).
* 3. Mask images do not repeat by default (opinionated).
*/
*,
*::before,
*::after {
box-sizing: border-box; /* 1 */
background-repeat: no-repeat; /* 2 */
mask-repeat: no-repeat; /* 3 */
}
/*
1. A prerequisite for the 'body' to be able to fill the viewport height (requires 'body { min-block-size: 100%; }', see 'body' rule below). Reference: https://codepen.io/germanfrelo/pen/jOGNpbj
2. Use a sans serif font by default.
3. The default 'normal' line-height is tightly spaced, but takes font-metrics into account, which is important for many fonts. Looser spacing may improve readability in latin type, but may cause problems in some scripts -- from cursive/fantasy fonts to Javanese, Persian, and CJK languages.
4. Breaks words to prevent text overflow.
5. Use a 4-space tab width instead of the default 8.
6. Prevent WebKit-based browsers on iOS (all iOS browsers) from automatically increasing the default text size in landscape orientation. Reference:
- https://kilianvalkhof.com/2022/css-html/your-css-reset-needs-text-size-adjust-probably/
- https://css-tricks.com/your-css-reset-needs-text-size-adjust-probably/
7. Prevent unwanted layout shifts caused by scrollbars when text get longer.
*/
html {
block-size: 100%; /* 1 */
font-family: sans-serif; /* 2 */
line-height: 1.5; /* 3 */
overflow-wrap: break-word; /* 4 */
tab-size: 4; /* 5 */
-webkit-text-size-adjust: none; /* 6 */
scrollbar-gutter: stable; /* 7 */
}
/*
Smooth scrolling, but only when focused in the page to prevent unnaturally scrolling when tabbing though the results of a search.
*/
html:focus-within {
scroll-behavior: smooth;
}
/*
When users prefer reduced motion:
1. Remove fixed background attachment.
2. Remove transitions.
3. Remove animations/immediately jump any animation to the end point.
4. Remove timed scrolling behaviors.
*/
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
background-attachment: initial !important; /* 1 */
transition-delay: 0s !important; /* 2 */
transition-duration: 0s !important; /* 2 */
animation-duration: 1ms !important; /* 3 */
animation-delay: -1ms !important; /* 3 */
animation-iteration-count: 1 !important; /* 3 */
scroll-behavior: auto !important; /* 4 */
}
html:focus-within {
scroll-behavior: auto; /* 4 */
}
}
/*
When scrolling to target elements, a reasonable spacing is added above them to ensure they remain visible, especially with sticky headers or similar. Adjust as needed.
Reference: https://piccalil.li/blog/a-more-modern-css-reset/
*/
:target {
scroll-margin-block-start: 5em;
}
/* Sections
======================================== */
/*
1. Makes 'body' at least as tall as the viewport height (requires 'html { block-size: 100%; }', see 'html' rule above). Reference: https://codepen.io/germanfrelo/pen/jOGNpbj
2. Remove the tiny space around the edge of the page.
*/
body {
min-block-size: 100%; /* 1 */
margin: 0; /* 2 */
}
/*
Correct the font size and margin on 'h1' elements within 'section' and 'article' contexts in Chrome, Firefox, and Safari.
*/
:where(h1) {
margin-block: 0.67em;
font-size: 2em;
}
/*
The default 'normal' line-height is tightly spaced, but takes font-metrics into account, which is important for many fonts. Looser spacing may improve readability in latin type, but may cause problems in some scripts -- from cursive/fantasy fonts to Javanese, Persian, and CJK languages.
*/
h1,
h2,
h3,
h4,
h5,
h6 {
line-height: 1.25;
}
/*
Switch to rem units for headings.
*/
h1 {
font-size: 2rem;
}
h2 {
font-size: 1.5rem;
}
h3 {
font-size: 1.17rem;
}
h4 {
font-size: 1rem;
}
h5 {
font-size: 0.83rem;
}
h6 {
font-size: 0.67rem;
}
/* Grouping content
======================================== */
/*
1. Correct the inheritance and scaling of font size in all browsers.
2. Correct the odd 'em' font sizing in all browsers.
3. Prevent overflow of the container.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
white-space: pre-wrap; /* 3 */
}
/*
Sets a consistent and modern default look for 'hr':
1. Reverts the default 'gray' color in Firefox and Safari to allow the text foreground color to be used as the border color.
2. Removes all default '1px inset' borders to instead use a single border with a 'solid' style and a border width of '2px' to have the same height as before.
*/
hr {
color: inherit; /* 1 */
border: none; /* 2 */
border-block-start: 2px solid; /* 2 */
}
/*
The default 'normal' line-height is tightly spaced, but takes font-metrics into account, which is important for many fonts. Looser spacing may improve readability in latin type, but may cause problems in some scripts -- from cursive/fantasy fonts to Javanese, Persian, and CJK languages.
*/
figcaption {
line-height: 1.375;
}
/*
Replace '40px' indents with '2.5em' indents.
*/
:where(blockquote, figure) {
margin-inline: 2.5em;
}
:where(ul, ol, menu) {
padding-inline-start: 2.5em;
}
:where(dd) {
margin-inline-start: 2.5em;
}
/* Text-level semantics
======================================== */
/*
Add the correct font weight in Chrome and Safari.
*/
b,
strong {
font-weight: bolder;
}
/*
1. Correct the inheritance and scaling of font size in all browsers.
2. Correct the odd 'em' font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Embedded content
======================================== */
/*
1. Block display is usually what we want.
2. Responsive by default.
3. The 'vertical-align' removes strange space-below in case authors overwrite the 'display' value.
*/
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
display: block; /* 1 */
max-inline-size: 100%; /* 2 */
vertical-align: middle; /* 3 */
}
/*
The display is inline by default, but that's not the expected behavior. This can interfere with proper layout and aspect-ratio handling.
1. Remove the unnecessary wrapping 'picture', while maintaining contents.
2. Source elements have nothing to display, so we hide them entirely.
*/
picture {
display: contents; /* 1 */
}
source {
display: none; /* 2 */
}
/*
Maintain intrinsic aspect ratios when 'max-inline-size' is applied ('iframe', 'embed, and 'object' are also embedded, but have no intrinsic ratio, so their 'block-size' needs to be set explicitly).
*/
img,
svg,
video,
canvas {
block-size: auto;
}
/*
There is no good reason elements default to 300px, and audio files are unlikely to come with a width attribute.
*/
audio {
inline-size: 100%;
}
/*
Change the fill color to match the text color.
*/
svg:not([fill]) {
fill: currentcolor;
}
/*
Change the border appearance.
*/
iframe {
border-color: currentcolor;
border-style: solid;
}
/* Tabular data
======================================== */
/*
1. Collapse border spacing.
2. Correct table border color inheritance in Chrome and Safari.
*/
table {
border-collapse: collapse; /* 1 */
border-color: currentcolor; /* 2 */
}
/*
The default 'normal' line-height is tightly spaced, but takes font-metrics into account, which is important for many fonts. Looser spacing may improve readability in latin type, but may cause problems in some scripts -- from cursive/fantasy fonts to Javanese, Persian, and CJK languages.
*/
caption {
line-height: 1.375;
}
/*
Make 'th' alignment consistent with 'td' alignment.
*/
th {
text-align: start;
}
/*
Add paddings and borders to table cells.
*/
:where(th, td) {
padding-block: 0.25em;
padding-inline: 0.5em;
border: 1px solid;
}
/* Forms
======================================== */
/*
1. Remove the margin on controls in all browsers.
2. Add typography inheritance.
*/
button,
input,
select,
textarea {
margin: 0; /* 1 */
font: inherit; /* 2 */
letter-spacing: inherit; /* 2 */
word-spacing: inherit; /* 2 */
}
/*
Sets a default placeholder color that is accessible and consistent across browsers for both light (default) and dark color schemes.
Reference: https://codepen.io/germanfrelo/pen/EaYwZdb
*/
::placeholder {
color: #757575;
}
@supports (color: light-dark(black, white)) {
::placeholder {
color: light-dark(hsl(0deg 0% 46%), hsl(0deg 0% 65%));
}
}
/*
Change font properties to 'inherit' in Safari.
*/
::file-selector-button {
font: inherit;
}
/*
1. Remove the margin.
2. Change the border appearance.
*/
fieldset {
margin-inline: 0; /* 1 */
border-color: currentcolor; /* 2 */
border-style: solid; /* 2 */
}
/*
The default 'normal' line-height is tightly spaced, but takes font-metrics into account, which is important for many fonts. Looser spacing may improve readability in latin type, but may cause problems in some scripts -- from cursive/fantasy fonts to Javanese, Persian, and CJK languages.
*/
label,
legend {
line-height: 1.375;
}
/*
Responsive by default by restricting sizing to the page width.
*/
input,
select,
textarea {
max-inline-size: 100%;
}
/*
Set 'vertical-align' to middle.
*/
[type="color" i],
[type="range" i] {
vertical-align: middle;
}
/*
Maintain 'hidden' behavior when overriding 'display' values.
*/
[hidden] {
display: none;
}
/*
Change the cursor on busy elements.
*/
[aria-busy="true" i] {
cursor: progress;
}
/*
Change the cursor on disabled, not-editable, or otherwise inoperable elements.
*/
[disabled],
[aria-disabled="true" i] {
cursor: not-allowed;
}
/*
Change the display on visually hidden accessible elements.
*/
[aria-hidden="false" i][hidden] {
display: initial;
}
[aria-hidden="false" i][hidden]:not(:focus) {
/* Visually hidden styles */
position: absolute !important;
inline-size: 1px !important;
block-size: 1px !important;
overflow: hidden !important;
clip-path: inset(50%) !important;
white-space: nowrap !important;
}
/* Interactive elements
======================================== */
/*
Change the cursor to feel it's interactive.
*/
summary {
cursor: default;
}