我已经使用 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>
这个小提琴做你想要的:
http://jsfiddle.net/ZczEt/9/
以下是处理右侧浮动元素$(‘#summary’)的javascript:
$('#summary').scrollToFixed({
marginTop:
$('.header').outerHeight() + 10,
limit:
$('.footer').offset().top -
$('#summary').outerHeight() -
10
});
这是jquery插件及其来源:
https://github.com/bigspotteddog/ScrollToFixed
