所以我有一个简单的引导页面,在这里我使用部分ID,然后在菜单上将它们定位为目标。问题是,当我单击菜单时,它会转到正确的部分,但菜单链接不会保持活动状态。只有向下滚动一点后,它才能激活。
当您有多个部分时,这是令人遗憾的,因为例如,我单击第3部分,它会转到第3部分,但是菜单活动链接仍然是数字2,直到我在第3部分上向下滚动
我该如何解决?这是网站:https://salpoente.pt/convite-carta/
答案 0 :(得分:1)
在文件scrolling-nav.js中,将第11行的“ 54”更改为“ 1”。
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: (target.offset().top - 1)
}, 1000, "easeInOutExpo");
return false;
}
}
});