【问题标题】:how to Scroll to the end of a div in a single scroll如何在单个滚动中滚动到 div 的末尾
【发布时间】:2014-07-24 19:56:09
【问题描述】:

我有一个屏幕高度为 100% 的 div,我希望它滚动 like this website。一个小卷轴应该带我到一个分区的末尾。

$('html, body').animate({
scrollTop: $("#target-element").offset().top
}, 1000);

我正在使用此代码,但它不起作用。帮助

【问题讨论】:

标签: javascript jquery html css scroll


【解决方案1】:

这段代码应该可以工作:

$( "body" ).scroll(function() {
    $('html, body').animate({
        scrollTop: $("#target-element").offset().top
    }, 1000);
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-09
    • 2019-04-03
    相关资源
    最近更新 更多