【发布时间】:2014-07-15 19:23:26
【问题描述】:
我使用了来自 CSS TRICKS 的 Smooth Scroll Plugin, 它工作得很好,但只有 2 个锚链接而不是另一个链接,请在此处查看演示,
它的工作非常适合行业和定价,但在推荐中,它只是跳转到该位置,并且固定导航也切断了该部分。
<script>
$(document).ready(function () {
$('a[href^="#"]').on('click', function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top - 130 // - 130px (nav-height)
}, 900, 'swing', function () {
// Replace this with something that can be easily parsed and used by your code
window.location.hash = '3' + target;
});
});
});
</script>
【问题讨论】:
标签: javascript jquery html css