From 11de9530e97a635ca852df37da10283d2cd8539f Mon Sep 17 00:00:00 2001 From: Nick Evans Date: Wed, 25 Oct 2023 21:20:17 -0500 Subject: [PATCH] ToC fixes for fixed header's height --- src/styles/markdown.scss | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/styles/markdown.scss b/src/styles/markdown.scss index e3d3060..cc9502a 100644 --- a/src/styles/markdown.scss +++ b/src/styles/markdown.scss @@ -5,6 +5,23 @@ * Copyright (c) 2021 Robert Guss. Used under the MIT License . */ .markdown-content { + /** + * This is a trick so the ToC will account for the height of the fixed header. + * + * Otherwise, the browser will scroll to the anchor and leave it underneath the nav bar, which is not quite what + * we wanted. + * + * The 115px is a "good enough" figure I came up with based on the heights of the bar on various screen sizes. This + * will reliably deliver users to the correct part of the page. + */ + [id]::before { + content: ''; + display: block; + height: 115px; + margin-top: -115px; + visibility: hidden; + } + h1, h2, h3 { @apply underline; }