我使用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>
像魅力一樣工作,謝謝! – markramos83 2011-12-06 16:33:53
很高興工作。這是一個有趣的要求弄清楚:) – bigspotteddog 2011-12-12 19:07:25
@bigspotteddog我很尷尬,如此無恥地劫持這條評論線程,但我想不出另一種方式來私下給你發消息。我很努力地使用你的插件scrolltofixed正確。如果你想快速看看[我的這個stackoverflow問題](http://stackoverflow.com/questions/10987447/scroll-multiple-sidebar-divs-down-the-screen-like-9gag-com-does/ 10989465)我會永遠感激。 – billmalarky 2012-06-16 09:29:42