Hello,
I have seen a few posts on this but I was hoping to maybe get a simpler answer. I am trying to create anchor links within a page. I have a sticky header. When I do this, the page scrolls too far down and covers the Title that I’m trying to go to. Is there a way to get it to go to the element in question, and not so far where the menu header covers the text? Do I have to do this via jquery or is there a simpler solution? Thanks.
I tried this solution but it didn’t seem to work: https://theme.co/apex/forums/topic/anchor-link-scrolls-too-far-top-is-covered-by-x-navbar/
jQuery(document).ready(function(){
jQuery('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
jQuerytarget = jQuery(target);
jQuery('html, body').stop().animate({
'scrollTop': jQuerytarget.offset().top-220
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
Thanks.
Jon