I am building a website with a fixed place menubar that is 35 px high on top of my page. In that menu I have four items that link to sections down the page. When I click on the links the page jumps to that section, but the 35 px menubar covers the top of the text.
How can I modify this site so that when I jump down to a section it doesn’t link me to the exact part of the HTML document, but 35 px higher to take into consideration the static menubar?
I am doing this with href code:
<a href="#links"><li>Links</li></a>
<h1><a name="links">Links</a></h1>
Thanks!
EDIT: Menubar code
<div id="top-floating-bar"> <!-- Menubar -->
<div class="row">
<div class="column grid_12">
<div class="fixed-bar-buttons">
<ul>
<a href="#top"><li>Home</li></a>
<a href="#links"><li>Links</li></a>
<a href="#resume"><li>Resume</li></a>
<a href="#social"><li>Social</li></a>
</ul>
</div>
</div>
</div>
</div> <!-- End the Menubar -->
Description
You can use jQuery
.offset()and.scrollTop()functionUpdate after a discussion with tguidon
I don’t know how your
top-floating-barcss is defined, but i know what you want.The size of the menubar in the fiddle is not right, because i dont know your definition.
Check out the jSFiddle.
Sample
Html
More Information