0
我想弄清楚如何在頁面上達到某個點後停止滾動div,並且出於某種原因,我無法使其正常工作。停止在某個div的滾動
這是它顯示了當我滾動一路頁腳的底部,但我希望它達到一個單元DIV結束後停止
周圍的整個部分的DIV是:
content
我的jQuery:
jQuery(function($) {
var $el = $('#scroll'),
top = $el.offset().top;
$(window).scroll(function() {
var pos = $(window).scrollTop();
if (pos > top && !$el.hasClass('fixed')) {
$el.addClass('fixed');
} else if (pos < top && $el.hasClass('fixed')) {
$el.removeClass('fixed');
}
});
});
我的CSS:
#scroll.fixed {
position: fixed;
top: 20%;
}
#scroll {
position: absolute;
top: 50px;
}
我試圖
stopPosition = $('.content').offset().top;
,但沒有運氣。