-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
947 lines (746 loc) · 25.2 KB
/
index.html
File metadata and controls
947 lines (746 loc) · 25.2 KB
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
<!DOCTYPE html>
<html lang="en">
<head>
<title>Boring CSS Library</title>
<meta name="description" content="Just a boring CSS library.">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/boringcss/">
<!-- fonts, optional but recommended -->
<link rel="preload" href="./boring/font/commissioner.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="./boring/font/fira-code-regular.woff2" as="font" type="font/woff2" crossorigin>
<link rel = "stylesheet" href = "./boring/font/commissioner.css">
<link rel = "stylesheet" href = "./boring/font/fira-code.css">
<!-- this library -->
<link rel = "stylesheet" href = "./boring/base.css">
<link rel = "stylesheet" href = "./boring/layout.css">
<link rel = "stylesheet" href = "./boring/text.css">
<link rel = "stylesheet" href = "./boring/form.css">
<!-- additional css for this page, not a part of the library -->
<link rel = "stylesheet" href = "./index.css">
</head>
<body>
<div class = "fade"></div>
<menu>
<div class = "menu-title">
Boring CSS Library
</div>
<div id = "nav-toggle">
<b>☰</b> Menu
</div>
<nav>
<ol type = "none" id = "toc">
<li><strong>Contents</strong></li>
</ol>
<p class = "search">
<kbd>Ctrl</kbd><kbd>F</kbd> to search
</p>
<hr>
<strong>Author</strong>
<address>
Github: <a href = "//github.com/intredford" class="link">@intredford</a><br>
Email: <a href = "mailto:mail@dimius.ru" class="link">mail@dimius.ru</a><br>
Blog<sup>ru</sup>: <a href = "//rant.dimius.ru" class="link">rant.dimius.ru</a><br>
</address>
</nav>
</menu>
<section class = "container">
<h1 class = "main-title">Boring CSS</h1>
<p>A generic style library for simple projects.</p>
</section>
<section class = "container">
<h2 id = "introduction">Introduction</h2>
<p>
This library is a lightweight CSS toolkit for quick styling of small user interfaces.
It avoids enforcing any specific trendy design choices and does not attempts to be a complex UI framework.
Instead, it's just a collection of basic styles for common HTML elements.
</p>
<p>
Don't be afraid to customize it. In fact, I encourage you to do so!
</p>
</section>
<section class = "container">
<h2 id = "installation">Installation</h2>
<p>It's simple. Just download these files need and import them into your project however you prefer:</p>
<ul>
<li>
<a href = "./boring/base.css" class="link" target="_blank">
base.css;
</a>
</li>
<li>
<a href = "./boring/text.css" class="link" target="_blank">
text.css
</a>
— static text elements, like headings, lists, code, tables, etc;
</li>
<li>
<a href = "./boring/layout.css" class="link" target="_blank">
layout.css
</a>
— very basic layout components: just container and row;
</li>
<li>
<a href = "./boring/form.css" class="link" target="_blank">
form.css
</a>
— form elements and other interactive stuff;
</li>
<li>
<a href = "./boring/font/commissioner.css" class="link" target="_blank">commissioner.css,</a>
<a href = "./boring/font/commissioner.woff2" class="link" target="_blank">commissioner.woff2;</a>
</li>
<li>
<a href = "./boring/font/fira-code.css" class="link" target="_blank">fira-code.css,</a>
<a href = "./boring/font/fira-code-regular.woff2" class="link" target="_blank">fira-code-regular.woff2.</a>
</li>
</ul>
<p>Or just download the <a href = "//github.com/intredford/boringcss" class="link" target="_blank">repository.</a></p>
<p><i>Styles are split between files just to make editing easier. This library isn't actually modular. In production you should consider bundling it all into a single file.</i></p>
</section>
<section id = "demo">
<div class = "container">
<h1>Demo</h1>
<p>Below you'll find all the components available. To see the code, just inspect the source code of the section in your browser.</p>
<p>Source code is also available on <a href = "//github.com/intredford/boringcss" class="link" target="_blank">Github</a>.</p>
<h2 id = "text">Text</h2>
<p>This section demonstrates the styling of typographic and generally static elements.</p>
<h3 id = "headings-and-paragraphs">Headings and Paragraphs</h3>
<p>
Styles of text and headings heavily relies on your desired structure of page,
and you will probably have to edit these styles.
On this site, only three levels of headings are used.
</p>
<p>Aside from classic heading tags, you can use <code>.h1</code> — <code>.h6</code> classes.</p>
<h3 id = "text-and-colors">Text colors</h3>
<p>Text can be colored with classes:</p>
<div>
<code class="text-blue">.text-blue </code>
<code class="text-red">.text-red </code>
<code class="text-green">.text-green </code>
<code class="text-purple">.text-purple </code>
<code class="text-yellow">.text-yellow </code>
<code class="text-orange">.text-orange </code>
<code class="text-black">.text-black </code>
<code class="text-white">.text-white </code>
</div>
<p>In dark theme black and white are reversed.</p>
<h3 id = "lists">Lists</h3>
<p>By default, <code><ul></code> and <code><ol></code> look like this:</p>
<div class = "row">
<div class = "example-list">
Unordered list:
<ul>
<li>Pulp Fiction;</li>
<li>Reservoir Dogs;</li>
<li>Kill Bill;</li>
<li>Hateful Eight;</li>
<li>Once Upon a Time in Hollywood;</li>
<li>Django Unchained;</li>
<li>Inglourious Basterds.</li>
</ul>
</div>
<div class = "example-list">
Ordered list:
<ol>
<li>Get up;</li>
<li>Have breakfast;</li>
<li>Watch TV;</li>
<li>Have a dinner;</li>
<li>Take a nap;</li>
<li>Watch TV;</li>
<li>Go to bed.</li>
</ol>
</div>
</div>
<p>To change the marker, edit <code>--list-character</code> variable in your <code>text.css</code>.</p>
<h3 id = "code">Code</h3>
<p>
<code><code> looks like this</code>
</p>
<pre>
<code>const message = "<pre> looks like this"
setTimeout(() => {
console.log(message)
}, 7000)</code>
</pre>
<h3 id = "kbd">Keybind</h3>
<p><code><kbd></code> looks like this: <kbd>Alt</kbd><kbd>F4</kbd>, <kbd>⌘</kbd><kbd>С</kbd>, etc.</p>
<h3 id = "tables">Table</h3>
<p>Default table:</p>
<table class = "hanging">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Franchise</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alucard</td>
<td>500s</td>
<td>Hellsing Manor, UK</td>
<td>Hellsing</td>
</tr>
<tr>
<td>Sherlock Holmes</td>
<td>34</td>
<td>221B Baker Street, London, UK</td>
<td>Sherlock Holmes</td>
</tr>
<tr>
<td>Winnie the Pooh</td>
<td>3</td>
<td>Hundred Acre Wood</td>
<td>Winnie the Pooh</td>
</tr>
</tbody>
</table>
<p><code>.bordered</code> table:</p>
<table class = "bordered hanging">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Franchise</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alucard</td>
<td>500s</td>
<td>Hellsing Manor</td>
<td>Hellsing</td>
</tr>
<tr>
<td>Sherlock Holmes</td>
<td>34</td>
<td>221B Baker Street, London, UK</td>
<td>Sherlock Holmes</td>
</tr>
<tr>
<td>Winnie the Pooh</td>
<td>3</td>
<td>Hundred Acre Wood</td>
<td>Winnie the Pooh</td>
</tr>
</tbody>
</table>
<p><code>.compact</code> tables:</p>
<table class = "compact hanging">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Franchise</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alucard</td>
<td>500s</td>
<td>Hellsing Manor</td>
<td>Hellsing</td>
</tr>
<tr>
<td>Sherlock Holmes</td>
<td>34</td>
<td>221B Baker Street, London, UK</td>
<td>Sherlock Holmes</td>
</tr>
<tr>
<td>Winnie the Pooh</td>
<td>3</td>
<td>Hundred Acre Wood</td>
<td>Winnie the Pooh</td>
</tr>
</tbody>
</table>
<table class = "compact bordered hanging">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Franchise</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alucard</td>
<td>500s</td>
<td>Hellsing Manor</td>
<td>Hellsing</td>
</tr>
<tr>
<td>Sherlock Holmes</td>
<td>34</td>
<td>221B Baker Street, London, UK</td>
<td>Sherlock Holmes</td>
</tr>
<tr>
<td>Winnie the Pooh</td>
<td>3</td>
<td>Hundred Acre Wood</td>
<td>Winnie the Pooh</td>
</tr>
</tbody>
</table>
<p>All four tables above use <code>.hanging</code> to align the first column with the left margin.</p>
<h3 id = "image">Image</h3>
<figure>
<img src = "./image.png" height = "160px" style = "height: 160px; image-rendering: pixelated;">
<figcaption>
Images are responsive, just as you would expect. I also made them block elements instead of inline.
</figcaption>
</figure>
<h3 id = "quote">Quote</h3>
<p>
<code><blockquote></code> with a <code><cite></code> looks like this:
</p>
<blockquote>
<p>
Wikipedia is the best thing ever. Anyone in the world can write anything they want about
any subject so you know you are getting the best possible information.
</p>
</blockquote>
<p>
<small>— Michael Scott, <cite>from the 18th episode of the 3rd season of The Office</cite></small>
</p>
<h3 id = "link">Link</h3>
<p>
<code>.link</code> <a href="javascript:void(0)" class="link">looks like this.</a> Links with <code><strong></code> and <code><b></code> inside them have <a href = "javascript:void(0)" class="link"><b>thick underline</b></a>.
</p>
<p>
<a href="javascript:void(0)">Notice that <code><a></code> tag itself is not styled.</a>
</p>
<h3 id = "underline">Underline</h3>
<p>
<code><u></code> behaves <u>basically same as link</u>. <u><b>Bold underlines</b></u> work too.
</p>
<h3 id = "strikethrough">Strikethrough</h3>
<p>
<code><s></code> behaves <s>basically</s> same as link and underline. <s><b>Bold strikethroughs</b></s> work too.
</p>
<h3 id = "marked-text">Marked text</h3>
<p>
<mark>Using <code><mark></code> to highlight text will look like this.</mark>
</p>
<p>
Marked text inside <code><i></code> <i>will have <mark>skewed</mark> background.</i> But note that if you're using your own font, you'll have to adjust CSS to match it's italic version.
</p>
<h3 id = "abbreviation">Abbreviation</h3>
<p>
<code><abbr></code> has spaced out letters: <abbr>HTML</abbr>.
It is useful to detect them automatically using script.
</p>
<p>
When <code>title</code> is provided, underline will appear: <abbr title = "Hyper Text Transfer Protocol Secure">HTTPS</abbr>.
</p>
<h3 id = "figure">Figure and caption</h3>
<div class = "row" style = "align-items: flex-end; flex-wrap: nowrap; max-width: 100%; overflow-x: auto;">
<figure>
<div style = "
background: color-mix(in srgb, var(--color-yellow), transparent 40%);
clip-path: polygon(0% 30%, 35% 30%, 35% 0%, 85% 0%, 100% 0%, 100% 30%, 100% 70%, 70% 70%, 70% 100%, 30% 100%, 0% 100%, 0% 70%);
width: 180px;
height: 110px;
padding: 0 10px 0 70px;
font-weight: 200;
font-size: 36px;
line-height: 0.95;
">some thing idk</div>
<figcaption>
Figure above is captioned with <code><figcaption></code>
</figcaption>
</figure>
<figure>
<pre><code>sudo chmod -R 777 /</code></pre>
<figcaption>
You can caption anything: media, tables, text, etc.
</figcaption>
</figure>
<figure>
<figcaption>
Placing caption above works too
</figcaption>
<div style = "
background: color-mix(in srgb, var(--color-orange), transparent 70%);
color: var(--color-red);
width: 8rem;
font-weight: 900;
font-variation-settings: 'FLAR' 100;
font-size: 1.3rem;
padding: 0.3em;
text-align: center;
place-content: center;
letter-spacing: 0.05em;
word-wrap: break-word;
line-height: 1.05;
">αβγδεζηθικλμνξοπρστυφχψω</div>
</figure>
</div>
<h3 id = "framed">Framed</h3>
<div class = "framed">
<code>.framed</code> looks like this.
</div>
<h3 id = "black-and-white">Black and white</h3>
<p class = "bw">
<code>.bw</code> looks like this <span title = "This pizza is very old">🍕</span>
</p>
<h3 id = "separators">Separators</h3>
<p>
<code><hr></code> looks like this:
</p>
<hr />
<p>
<code>.dinkus</code> looks like this:
</p>
<div class = "dinkus"></div>
<h2 id = "interactive-elements">Interactive Elements</h2>
<p>Here's what <code>forms.css</code> controls.</p>
<h3 id = "button">Button</h3>
<p>
Default <code><button></code> looks like this:
</p>
<div class = "row" style = "align-items: flex-start">
<button>Submit</button>
<figure style = "margin: 0">
<button disabled>Access</button>
<figcaption>
<small>Always clarify why something is disabled!</small>
</figcaption>
</figure>
</div>
<p>
If you want to fool around a bit, you can use colored buttons, using <code>.{color}</code> and <code>.text-{color}</code> classes:
</p>
<div class = "row demo-buttons-group" style = "margin-bottom: 1em;">
<button class="blue">Submit</button>
<button class="red">Delete</button>
<button class="green">Confirm</button>
<button class="purple">Later</button>
<button class="yellow">Collect</button>
<button class="orange">Buy</button>
<button class="black">Log out</button>
</div>
<div class = "row demo-buttons-group">
<button class="text-blue">Submit</button>
<button class="text-red">Delete</button>
<button class="text-green">Confirm</button>
<button class="text-purple">Later</button>
<button class="text-yellow">Collect</button>
<button class="text-orange">Buy</button>
<button class="text-black">Log out</button>
</div>
<br>
<p>
To get wide buttons, add <code>.block</code>:
</p>
<button class = "block">Unsubscribe from everything</button>
<br>
<p>To scale buttons, just use <code>font-size</code> CSS property:</p>
<div class = "row">
<button style = "font-size: 50%;">Submit</button>
<button style = "font-size: 125%;">Submit!</button>
<button style = "font-size: 200%;">Submit!!</button>
</div>
<br>
<p>
Note that buttons made with <code><input type="button|reset|submit"></code> are not styled.
If you need them, just edit the selectors.
</p>
<h3 id = "inputs">Inputs</h3>
<p>They look like this:</p>
<form class = "row">
<label>
Text
<input type="text" required />
</label>
<label>
Number
<input type="number" size="6" required />
</label>
<label>
Password
<input type="password" required />
</label>
<label>
Color
<input type="color" value="#e2cfcf" required />
</label>
<label>
Datetime Local
<input type="datetime-local" required />
</label>
<label>
Time
<input type="time" required />
</label>
</form>
<h4 id = "textarea">Textarea</h4>
<p><code><textarea></code> look like this:</p>
<label>
Address
<textarea placeholder="308 Negra Arroyo Lane"></textarea>
</label>
<p>Notice that horizontal resizing is disabled by default.</p>
<h4 id = "checkbox">Checkbox</h4>
<p><code><input type="checkbox"></code> with label looks like this:</p>
<label>
<input type = "checkbox">
Recieve spam
</label>
<h4 id = "radio">Radio</h4>
<p><code><input type="radio"></code> with label looks like this:</p>
<label>
<input type="radio" name="browser" value="firefox">
Firefox
</label>
<label>
<input type="radio" name="browser" value="chrome">
Chrome
</label>
<label>
<input type="radio" name="browser" value="safari">
Safari
</label>
<h4 id = "select">Select</h4>
<p><code><select></code> looks like this:</p>
<select>
<option>Firefox</option>
<option>Chrome</option>
<option>Safari</option>
<option>Internet Explorer</option>
</select>
<h4 id = "range">Range</h4>
<p><code><input type="range"></code> is unstyled, and with <code><datalist></code> it looks like this:</p>
<input type="range" list="markers" min="20" max="80" step="10" />
<datalist id="markers">
<option value="20"></option>
<option value="30"></option>
<option value="40"></option>
<option value="50"></option>
<option value="60"></option>
<option value="70"></option>
<option value="80"></option>
</datalist>
<p>You can also use <code>.vertical</code> ranges:</p>
<div class = "row">
<input type="range" class="vertical" min="0" max="100" step="1" value="70"/>
<input type="range" class="vertical" min="0" max="100" step="1" value="33"/>
<input type="range" class="vertical" min="0" max="100" step="1" value="80"/>
<input type="range" class="vertical" min="0" max="100" step="1" value="50"/>
<input type="range" class="vertical" min="0" max="100" step="1" value="9"/>
</div>
<h4 id = "file">File</h4>
<p><code><input type="file"></code> reuses button styles:</p>
<div class = "row">
<input type = "file">
<input type = "file" class = "blue">
</div>
<h3 id = "fieldset">Fieldset</h3>
<p><code><fieldset></code> with <code><legend></code> looks like this:</p>
<form>
<fieldset>
<legend>Look! Do you like it?</legend>
<label>
<input type="radio" name="like" value="yes">
Yes
</label>
<label>
<input type="radio" name="like" value="yes">
Yes
</label>
<fieldset>
<legend>Can I nest it?</legend>
<label>
<input type="checkbox">
Yes
</label>
<label>
<input type="checkbox" disabled>
No
</label>
</fieldset>
<fieldset>
<legend>What do you think?</legend>
<label>
Comment
<textarea></textarea>
</label>
</fieldset>
</fieldset>
</form>
<small>
<p>✎<i> Tip: to align <code><legend></code>, use <code>margin</code> instead of <code>text-align</code>.</i></p>
</small>
<h3 id = "details">Details</h3>
<details>
<summary>This is an accordion (e.g. collapsible). Use it wisely!</summary>
<p>
<b>Accordions are extremely annoying.</b>
They’re generally considered bad UX and can be an accessibility nightmare — especially when
they are inside forms. This library does include a minimal style for them, but honestly,
I wouldn’t recommend using them. There’s almost always a better solution, so think twice before
resorting to <code><details></code>.
</p>
</details>
<h3 id = "progress">Progress</h3>
<p><code><progress></code> looks like this:</p>
<label>
Deleting C:\Users\dima\dev\boringcss...
<progress value = "64" max = "100">64%</progress>
</label>
<label class = "text-red">
Applying <code>.text-red</code>...
<progress value = "88" max = "100">88%</progress>
</label>
<label class = "text-green">
Done!
<progress value = "100" max = "100">100%</progress>
</label>
<p>
Sadly, indeterminate state is not supported because CSS kills it.
Instead, <code>.spinner</code> is available:
</p>
<div class = "row" style = "gap: 0.4em">
<span class = "spinner"></span> Deleting C:\Users\dima\dev\boringcss...
</div>
<p>
<code><meter></code> is not supported either because it's impossible to properly style in Firefox.
After fifteen damn years!
</p>
</div>
</section>
<section class = "container">
<h2 id = "font">Font</h2>
<p>
This page uses the Commissioner font by Kostas Bartsokas.
Its metrics are uneven, so to <a href = "//tonsky.me/blog/centering" class="link">vertically center</a>
text by uppercase characters, these overrides are applied:
</p>
<div class = "row nowrap" style = "margin-block-start: -0.25em">
<pre class="hanging" style = "margin-block-start: 0">
<code>@font-face { ...
<a href = "//developer.mozilla.org/en-US/docs/Web/CSS/@font-face/ascent-override" class="link">ascent-override:</a> 96.3%;
<a href = "//developer.mozilla.org/en-US/docs/Web/CSS/@font-face/descent-override" class="link">descent-override:</a> 25%;
}</code>
</pre>
<div class = "example-letter">
<div>K</div>
<small>
Perfectly centered
</small>
</div>
<div class = "example-letter" style = "font-family: 'Tahoma'">
<div>K</div>
<small>
Not centered (most fonts)
</small>
</div>
</div>
<p>The values are calculated by balancing the space above and below uppercase letters, where descent is 25% of the em size. Key formula is:</p>
<pre>
<code>D = your desired descent
ascentOverride = (capHeight + D) / unitsPerEm × 100%
descentOverride = D / unitsPerEm × 100%</code>
</pre>
<p>For Commissioner it would be:</p>
<pre>
<code>D = 500
capHeight = 1426
unitsPerEm = 2000
ascentOverride = (1426 + 500) / 2000 × 100% = 96.3%
descentOverride = 500 / 2000 × 100% = 25%</code>
</pre>
<h3 id = "overrides">Overrides calculator (β)</h3>
<p>If you want to use a different font, you can use the calculator below.</p>
<div id = "overrides-calculator">
<div>
<p><b>Step 1:</b> Go to <a href="//seek-oss.github.io/capsize" target="_blank" class="link">Capsize</a>, pick or upload your font, and copy its metrics in JSON here:</p>
<textarea name = "metrics" class = "font-mono" rows="21" placeholder="{..."></textarea>
</div>
<div>
<p><b>Step 2:</b> Add the lines below into your <code>@font-face</code></p>
<pre>
<code>ascent-override:
descent-override:</code>
</pre>
</div>
</div>
<script>
const textarea = document.querySelector("#overrides-calculator textarea")
const css = document.querySelector("#overrides-calculator pre > code")
function getOverrides() {
try {
const metrics = eval('(' + textarea.value + ')')
const D = metrics.unitsPerEm * 0.25
const overrides = {
ascent: (metrics.capHeight + D) / metrics.unitsPerEm * 100,
descent: D / metrics.unitsPerEm * 100
}
if (isNaN(overrides.ascent) || isNaN(overrides.descent)) throw Error()
css.textContent = `ascent-override: ${+overrides.ascent.toFixed(2)}%;\n`
+ `descent-override: ${+overrides.descent.toFixed(2)}%;`
} catch (err) {
console.error("Can't calculate font overrides.", err)
css.textContent = `ascent-override: \n` + `descent-override: `
}
}
textarea.addEventListener("input", getOverrides)
getOverrides()
</script>
</section>
<section class = "container">
<h2 id = "feedback">Feedback</h2>
<p>If you have a suggestion or found a bug, please <a href = "//github.com/intredford/boringcss/issues" class="link" target="_blank">open an issue</a> or <a href = "mailto:mail@dimius.ru" class="link">email me.</a> </p>
<p>Before suggesting a change, please note that components must not require:</p>
<ul>
<li>JavaScript;</li>
<li>Complex markup or unintuitive applications of <code>label</code>, <code>:checked</code>, etc.</li>
</ul>
<p>Other than that, I'll be happy to recieve any feedback.</p>
</section>
<section class = "container">
<h2 id = "future-plans">Future plans</h2>
<p>I'm planning to add:</p>
<ul>
<li><a href="//developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog" class="link">Dialog</a> styles;</li>
<li><a href="//developer.mozilla.org/en-US/docs/Web/HTML/Element/picture" class="link">Picture</a> styles;</li>
<li>Better invalid state for inputs;</li>
<li>Traditional two-column forms (labels in one column, controls in another);</li>
<li><code>.line</code> inputs;</li>
<li><code>.quiet</code> buttons (no gradient, no press animation);</li>
<li>More clear division between modules;</li>
<li>More CSS variables to configure;</li>
<li>Maybe improved interactive documentation with code examples (most components are just a single tag, though).</li>
</ul>
</section>
<section class = "container">
<h2 id = "license">Licensing Stuff</h2>
<p>This library is MIT licensed, so you can do whatever you want.</p>
<p>For more info refer to <a href = "//github.com/intredford/boringcss" class="link" target="_blank">library's repo.</a></p>
</section>
<footer>
<div class = "container">
Boring CSS library by dimius
<aside>End of page</aside>
</div>
</footer>
<div class="debugger is__active container">
<div class="debugger-cols">
<div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div>
</div>
</div>
<script src = "index.js"></script>
</script>
</body>
</html>