ndabas/toc

How to add offset for anchor scrolling?

DN-FS opened this issue · 3 comments

DN-FS commented

Due to a fixed navigation header on a site, i would like to not jump directly to the clicked heading but 150px above the heading.
(So that the scrolled to heading is not hidden underneath the navigation header)

Thanks in advance!

ndabas commented

Well then this is probably not the right library for you to use, as this doesn't actually tell the browser to scroll to any offset -- the browser does the scrolling because of linked anchors.

DN-FS commented

You are right. i got it working with .css:
https://stackoverflow.com/a/24298427

Thanks!

ndabas commented

Cool, looks like a neat solution 👍