gpt4 book ai didi

jquery - 固定 float 元素停在页脚

转载 作者:行者123 更新时间:2023-11-28 09:14:40 25 4
gpt4 key购买 nike

我使用了 http://jqueryfordesigners.com/fixed-floating-elements 中的代码在滚动到某个点后 float 元素。这是我正在处理的网站: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>

最佳答案

这个 fiddle 可以满足您的需求:

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

这是处理右侧 float 元素 $('#summary') 的 javascript:

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

这是 jquery 插件及其来源:

https://github.com/bigspotteddog/ScrollToFixed

关于jquery - 固定 float 元素停在页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6102776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com