固定页脚处的浮动元素停止

mar*_*s83 3 css jquery scroll css-position footer

我已经使用http://jqueryfordesigners.com/fixed-floating-elements中的代码在滚动到某一点后浮动一个元素.这是我正在研究的网站:http://bodyecology.com/articles/gut-type-update

如您所见,右列在滚动时变为固定,但在页脚处重叠.如何让它停在页脚上方?

目前使用:

<script>
    jQuery(document).ready(function () {  
    var top = jQuery('#news_sidebar').offset().top - parseFloat(jQuery('#news_sidebar').css('marginTop').replace(/auto/, 0));
    jQuery(window).scroll(function (event) {

        var y = jQuery(this).scrollTop();

        if (y >= top) {

        jQuery('#news_sidebar').addClass('fixed');

        } else {

       jQuery('#news_sidebar').removeClass('fixed');
    }
  });
 });
</script>
Run Code Online (Sandbox Code Playgroud)

big*_*dog 6

这个小提琴做你想要的:

http://jsfiddle.net/ZczEt/9/

以下是处理右侧浮动元素$('#summary')的javascript:

$('#summary').scrollToFixed({
    marginTop:
        $('.header').outerHeight() + 10,
    limit:
        $('.footer').offset().top -
        $('#summary').outerHeight() -
        10
});
Run Code Online (Sandbox Code Playgroud)

这是jquery插件及其来源:

https://github.com/bigspotteddog/ScrollToFixed