Search code examples
htmlcssscrollhyperlinkhref

Scrolling to anchor on page results in element overlap


I have named a div id for example: div id="page1" and at the same page I have a link like: a href="#page1".

However, my navigation menu is always on top, so it hides under the menu on scroll. How can I fix it so that it will scroll exactly on the div?

I can't figure out how it can scroll exactly to the div.


Solution

  • What worked for me is using CSS:

    html { scroll-padding-top: 140px; }