Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (20.3k points)

If I have a non-scrolling header in an HTML page, fixed to the top, having a defined height:

Is there a way to use the URL anchor (the #fragment part) to have the browser scroll to a certain point in the page, but still respect the height of the fixed element without the help of JavaScript?

1 Answer

0 votes
by (40.7k points)

You can try adding a class to the anchor element with the topbar height as the padding-top value like this:

<h1><a class="anchor" name="barlink">Bar</a></h1>

If you are using css then use this:

.anchor { padding-top: 90px; }

Related questions

Browse Categories