我已经使用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)