我在页面上滚动的侧栏上有一个浮动div
。有没有办法添加代码,使其在到达页脚时停止?在行动获得一个浮动div在到达另一个div时停止
见代码:http://openbayou.staging.wpengine.com
用于浮动div
jQuery代码:
$j=jQuery.noConflict();
$j(document).ready(function($) {
//this is the floating content
var $floatingbox = $('#one');
if($('#primary').length > 0){
var bodyY = parseInt($('#primary').offset().top) - 20;
var originalX = $floatingbox.css('margin-left');
$(window).scroll(function() {
var scrollY = $(window).scrollTop();
var isfixed = $floatingbox.css('position') == 'fixed';
if($floatingbox.length > 0){
$floatingbox.html();
if (scrollY > 1561 && !isfixed) {
$floatingbox.stop().css({
position: 'fixed',
top: 10,
});
} else if (scrollY < 1561 && isfixed) {
$floatingbox.css({
position: 'relative',
top: 0,
});
}
}
});
}
});
这不是一个WordPress的问题,因此是脱离主题。 – vancoder 2013-04-24 22:11:59