@@ -257,24 +257,32 @@ main > ul {
257
257
258
258
/* Values for header margin-top and blockquote margin are taken from mdbook's general.css,
259
259
values for header margin-bottom are taken from <https://www.w3schools.com/cssref/css_default_values.php> */
260
+ : root {
261
+ /* 1.6 is body font-size */
262
+ --h2-margin-top : calc (1.5rem * 1.6 * 2.5 - 16px );
263
+ --h3-margin-top : calc (1.17rem * 1.6 * 2.5 - 16px );
264
+ --h4-margin-top : calc (1.00rem * 1.6 * 2 - 16px );
265
+ --h5-margin-top : calc (0.83rem * 1.6 * 2 - 16px );
266
+ --h6-margin-top : calc (0.67rem * 1.6 * 2 - 16px );
267
+ }
260
268
main > h2 {
261
- margin-top : calc ( 2.5 em - 16 px );
269
+ margin-top : var ( --h2-margin-top );
262
270
margin-bottom : calc (0.83em - 16px );
263
271
}
264
272
main > h3 {
265
- margin-top : calc ( 2.5 em - 16 px );
273
+ margin-top : var ( --h3-margin-top );
266
274
margin-bottom : calc (1em - 16px );
267
275
}
268
276
main > h4 {
269
- margin-top : calc ( 2 em - 16 px );
277
+ margin-top : var ( --h4-margin-top );
270
278
margin-bottom : calc (1.33em - 16px );
271
279
}
272
280
main > h5 {
273
- margin-top : calc ( 2 em - 16 px );
281
+ margin-top : var ( --h5-margin-top );
274
282
margin-bottom : calc (1.67em - 16px );
275
283
}
276
284
main > h6 {
277
- margin-top : calc ( 2 em - 16 px );
285
+ margin-top : var ( --h6-margin-top );
278
286
margin-bottom : calc (2.33em - 16px );
279
287
}
280
288
main > blockquote {
@@ -303,7 +311,7 @@ main > .rule {
303
311
}
304
312
305
313
/* Test links */
306
- .rule . popup-container {
314
+ .test-link {
307
315
float : right;
308
316
padding-right : 10px ;
309
317
}
@@ -317,51 +325,77 @@ main > .rule {
317
325
navigate to it. This adds an indicator that the linked rule is the one that
318
326
is "current", just like normal headers are in mdbook.
319
327
*/
320
- .rule : target a ::before {
328
+ .rule : target . rule-link ::before {
321
329
display : inline-block;
322
330
content : "»" ;
323
331
padding-right : 5px ;
324
332
}
325
333
326
334
/* Dodge » from headings */
327
- .rule : has (+ h1 : target ),
328
- .rule : has (+ h2 : target ),
329
- .rule : has (+ h3 : target ),
330
- .rule : has (+ h4 : target ),
331
- .rule : has (+ h5 : target ),
332
- .rule : has (+ h6 : target ) {
335
+ /* Note: Some rules have a .tests-popup in the way, so that's why this selects
336
+ either with or without. */
337
+ .rule : has (+ h1 : target , + .tests-popup + h1 : target ),
338
+ .rule : has (+ h2 : target , + .tests-popup + h2 : target ),
339
+ .rule : has (+ h3 : target , + .tests-popup + h3 : target ),
340
+ .rule : has (+ h4 : target , + .tests-popup + h4 : target ),
341
+ .rule : has (+ h5 : target , + .tests-popup + h5 : target ),
342
+ .rule : has (+ h6 : target , + .tests-popup + h6 : target ) {
333
343
padding-right : 24px ;
334
344
}
335
345
346
+ /* This positioning is to push the popup down over the header's top margin.
347
+ Ideally I would like the popup to show *below* the header, but I have no idea how to do that.
348
+ */
349
+ .tests-popup : has (+ h2 ) {
350
+ position : relative;
351
+ top : calc (var (--h2-margin-top ) + 10px );
352
+ }
353
+ .tests-popup : has (+ h3 ) {
354
+ position : relative;
355
+ top : calc (var (--h3-margin-top ) + 10px );
356
+ }
357
+ .tests-popup : has (+ h4 ) {
358
+ position : relative;
359
+ top : calc (var (--h4-margin-top ) + 10px );
360
+ }
361
+ .tests-popup : has (+ h5 ) {
362
+ position : relative;
363
+ top : calc (var (--h5-margin-top ) + 10px );
364
+ }
365
+ .tests-popup : has (+ h6 ) {
366
+ position : relative;
367
+ top : calc (var (--h6-margin-top ) + 10px );
368
+ }
369
+
336
370
/* Hide the rules if the width of the container is too small.
337
371
The cutoff point is chosen semi-arbitrary, it felt that
338
372
when `width < 14em`, there are too many breaks. */
339
373
@container rule (width < 14em) {
340
374
main > .rule a .rule-link span ,
341
- main > . rule . popup-container > a span {
375
+ . test-link > a span {
342
376
display : none;
343
377
}
344
378
345
379
main > .rule > a .rule-link ::before {
346
380
content : "[*]" ;
347
381
}
348
382
349
- main > . rule . popup-container > a ::before {
383
+ . test-link > a ::before {
350
384
content : "[T]" ;
351
385
}
352
386
}
353
387
354
388
/* Align rules to various siblings */
355
- .rule : has (+ p ),
356
- .rule : has (+ ul ) {
389
+ .rule : has (+ p , + . tests-popup + p ),
390
+ .rule : has (+ ul , + . tests-popup + ul ) {
357
391
margin-top : calc ((1em - var (--font-size )) / var (--font-size-mult ) / 2 );
358
392
}
359
393
360
- .rule : has (+ h1 ) {
394
+ .rule : has (+ h1 , + . tests-popup + h1 ) {
361
395
align-self : center;
362
396
}
363
397
364
- .rule : has (+ h2 ) {
398
+ .rule : has (+ h2 , + . tests-popup + h2 ) {
365
399
/* multiplying by this turns h2's em into .rule's em*/
366
400
--h2-em-mult : calc (
367
401
(1 / var (--font-size-mult )) /* to main font size */
@@ -375,7 +409,7 @@ main > .rule {
375
409
+ (1em * var (--h2-em-mult ) - 1em ) / 2
376
410
)
377
411
}
378
- .rule : has (+ h3 ) {
412
+ .rule : has (+ h3 , + . tests-popup + h3 ) {
379
413
/* multiplying by this turns h3's em into .rule's em*/
380
414
--h3-em-mult : calc (
381
415
(1 / var (--font-size-mult )) /* to main font size */
@@ -390,7 +424,7 @@ main > .rule {
390
424
)
391
425
}
392
426
393
- .rule : has (+ h4 ) {
427
+ .rule : has (+ h4 , + . tests-popup + h4 ) {
394
428
/* multiplying by this turns h4's em into .rule's em*/
395
429
--h4-em-mult : calc (
396
430
(1 / var (--font-size-mult )) /* to main font size */
@@ -405,7 +439,7 @@ main > .rule {
405
439
)
406
440
}
407
441
408
- .rule : has (+ h5 ) {
442
+ .rule : has (+ h5 , + . tests-popup + h5 ) {
409
443
/* multiplying by this turns h5's em into .rule's em*/
410
444
--h5-em-mult : calc (
411
445
(1 / var (--font-size-mult )) /* to main font size */
@@ -420,7 +454,7 @@ main > .rule {
420
454
)
421
455
}
422
456
423
- .rule : has (+ h6 ) {
457
+ .rule : has (+ h6 , + . tests-popup + h6 ) {
424
458
/* multiplying by this turns h6's em into .rule's em*/
425
459
--h6-em-mult : calc (
426
460
(1 / var (--font-size-mult )) /* to main font size */
0 commit comments