Reputation:
I think the title is enough to understanding my problem.
I'm working on a one page HTML template with fixed navigation bar. When I scroll down, it comes over my section title. I've coded like this:
<a href="#service"></a>
<section id="services"></section>
I want to scroll down just a little before top of my section.
Thank you.
Upvotes: 0
Views: 106
Reputation: 1907
I created this small snippet to solve a problem similar to this. http://codepen.io/mccell/pen/DdyKl/
There are some notes in the code. But basically it uses jquery's scrolltop to move the anchorlink to the top of the page but also adds the ability to offset with a custom data-offset attribute.
This is the main working part of the code.
$('html, body').animate({
scrollTop: $(target).offset().top-offsetValue
}, 1000);
Upvotes: 0
Reputation: 14172
Give the content div a padding-top
, or margin-top
of the height of the nav bar:
<a href="#link">Link</a>
<div id="link" class="content">
Content Here...
</div>
CSS:
.content{
padding-top:50px;
}
Upvotes: 1