trevortylerlee / astro-micro

Blog theme for Astro with search and comments built-in. Zero frameworks.
https://astro-micro.vercel.app
MIT License
203 stars 47 forks source link

Fix "ToC links are obscured by Header when scrolled to" #4

Closed blopker closed 6 months ago

blopker commented 6 months ago

Hey, thanks for this theme, it looks great. I saw the issue where the ToC links scroll too far. There's a handy CSS rule now that fixes that: scroll-padding-top: <value>; (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-top)

Basically you'd just need to add it to the html selector in global.css:

html {
  overflow-y: auto;
  color-scheme: light;
+  scroll-padding-top: 200px;
}

Now anchor links will always stop at 200px below the top of the viewport. This doesn't affect any of the padding on the page.

trevortylerlee commented 6 months ago

Thank you!!