将Sticky Div设置为滚动到顶部和底部的问题

时间:2014-01-18 07:52:31

标签: jquery scroll

你能不能对这个Demo采取行动,让我知道如何设置粘性div停留在视口的底部,并且还能够在页面的第二部分上下滚动页面在视口中。以下是This link中的示例。正如你所看到的那样

  

<div class="floating-bar evtFloatingBar"></div>

位于页面末尾并控制页面的滚动。以下是我试图创建的内容:

<div id="first">Here is the First Part</div>
<div id="scroller">Click Me</div>
<div id="second">Here is the Second Part</div>

<script>
$('#scroller').click(function() {
    $('html,body').animate({
        scrollTop: $('#second').css('top')
    }, 800, function() {

        $('html, body').animate({
            scrollTop: 0
        }, 800);
    });
});
</script>

谢谢你的时间

0 个答案:

没有答案