Mit folgenden Vanilla JS Code Schnipsel scrollen die Anker Links smart zu den Zielen.
for (let element of document.querySelectorAll('a[href^="#"]')) { element.addEventListener('click', (event) => { event.preventDefault(); let hash = element.getAttribute('href'); let target = document.getElementById(hash.substr(1)); if (target !== null) { let rect = target.getBoundingClientRect(); let top = (window.pageYOffset || document.documentElement.scrollTop) + rect.top; let offset = 92; window.scrollTo({ top: top - offset, behavior: "smooth" }); } }); }