Skip to content

Commit 1f12877

Browse files
committed
Add h5/h6 support
1 parent 13869f4 commit 1f12877

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

theme/reference.css

+43-3
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ main > ul {
255255
margin-bottom: 0;
256256
}
257257

258-
/* Values for h2/h3/h4 margin-top and blockquote margin are taken from mdbook's general.css,
259-
values for h2/h3/h4 margin-bottom are taken from <https://www.w3schools.com/cssref/css_default_values.php> */
258+
/* Values for header margin-top and blockquote margin are taken from mdbook's general.css,
259+
values for header margin-bottom are taken from <https://www.w3schools.com/cssref/css_default_values.php> */
260260
main > h2 {
261261
margin-top: calc(2.5em - 16px);
262262
margin-bottom: calc(0.83em - 16px);
@@ -269,6 +269,14 @@ main > h4 {
269269
margin-top: calc(2em - 16px);
270270
margin-bottom: calc(1.33em - 16px);
271271
}
272+
main > h5 {
273+
margin-top: calc(2em - 16px);
274+
margin-bottom: calc(1.67em - 16px);
275+
}
276+
main > h6 {
277+
margin-top: calc(2em - 16px);
278+
margin-bottom: calc(2.33em - 16px);
279+
}
272280
main > blockquote {
273281
margin-top: calc(20px - 16px);
274282
margin-bottom: calc(20px - 16px);
@@ -308,7 +316,9 @@ main > .rule {
308316
.rule:has(+ h1:target),
309317
.rule:has(+ h2:target),
310318
.rule:has(+ h3:target),
311-
.rule:has(+ h4:target) {
319+
.rule:has(+ h4:target),
320+
.rule:has(+ h5:target),
321+
.rule:has(+ h6:target) {
312322
padding-right: 24px;
313323
}
314324

@@ -379,6 +389,36 @@ main > .rule {
379389
)
380390
}
381391

392+
.rule:has(+ h5) {
393+
/* multiplying by this turns h5's em into .rule's em*/
394+
--h5-em-mult: calc(
395+
(1 / var(--font-size-mult)) /* to main font size */
396+
* 0.83 /* to h5 font size */
397+
);
398+
399+
margin-top: calc(
400+
/* h5 margin top */
401+
2em * var(--h5-em-mult) - 16px
402+
/* half of the font size difference */
403+
+ (1em * var(--h5-em-mult) - 1em) / 2
404+
)
405+
}
406+
407+
.rule:has(+ h6) {
408+
/* multiplying by this turns h6's em into .rule's em*/
409+
--h6-em-mult: calc(
410+
(1 / var(--font-size-mult)) /* to main font size */
411+
* 0.67 /* to h6 font size */
412+
);
413+
414+
margin-top: calc(
415+
/* h6 margin top */
416+
2em * var(--h6-em-mult) - 16px
417+
/* half of the font size difference */
418+
+ (1em * var(--h6-em-mult) - 1em) / 2
419+
)
420+
}
421+
382422
/* Sets the color for [!HISTORY] blockquote admonitions. */
383423
.history > blockquote {
384424
background: #f7c0eb;

0 commit comments

Comments
 (0)