【问题标题】:Smooth Scroll Jumps Rather than Scroll平滑滚动跳转而不是滚动
【发布时间】:2014-07-15 19:23:26
【问题描述】:

我使用了来自 CSS TRICKS 的 Smooth Scroll Plugin, 它工作得很好,但只有 2 个锚链接而不是另一个链接,请在此处查看演示,

LIVE DEMO

它的工作非常适合行业和定价,但在推荐中,它只是跳转到该位置,并且固定导航也切断了该部分。

<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


    【解决方案1】:

    我在这里做了一个 jsfiddle,
    jsfiddle.net/Thq62/

    只要在链接中添加适当的 id 和哈希,它就可以正常工作

    【讨论】:

    • 为链接添加了完美的 ID 和哈希,但仍然无法正常工作
    猜你喜欢
    • 2019-09-19
    • 1970-01-01
    • 2018-01-19
    • 1970-01-01
    • 2011-06-26
    • 1970-01-01
    • 1970-01-01
    • 2020-04-28
    • 1970-01-01
    相关资源
    最近更新 更多