2
我已经开始使用CSS-Tricks的代码,并且它与偏移量一起工作良好。问题是该网站有一个固定的标题,所以我需要它从另一个页面导航到内部链接时应用偏移量。目前它正在被切断。jQuery平滑滚动链接到其他页面上的偏移量
$('a[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-144
}, 1000);
return false;
}
}
});
任何帮助将不胜感激。有问题的页面是http://marketingmo.wpengine.com/services/#brand-development
这就是我正在寻找的。除了原始代码之外,我还使用了那一点代码,它们在一起玩的很好。谢谢马克! –