Hi you all!
I am building my portfolio page but I have a problem. When I click on a navbar link, it scrolls down and overlaps the title of each section. I tried the following workaround
$(document).ready(function(){
$('a[href^="#"]').click(function(e) {
e.preventDefault();
var target = this.hash, $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top-80
}, 300, 'swing', function() {
window.location.hash = target;
});
});
});
This works but it is not okay for me, since when I use the navigation bar, active section is not showing properly.
Original question by CrisBarreiro
To fix the nav link not showing as active when the section is at the bottom of the nav bar, you can add an offset to the scrollSpy like this:
<body data-spy="scroll" data-target="#myScrollspy" data-offset="80">
...
</body>
CrisBarreiro: That solved my problem, thank you!