2011-04-21 72 views
0

我一直使用这个固定的浮动侧栏礼貌(http://jqueryfordesigners.com/fixed-floating-elements/)。这很好,我唯一的问题是我不知道如何强制底部出来,所以固定位置永远不会比可视区域高。我的边栏可以添加内容,有时当边栏从底部的页面延伸出来的时候会有很多内容。有人能够朝正确的方向开枪吗?这里是侧边栏的JavaScript。底部固定浮动侧栏

var msie6 = $.browser == 'msie' && $.browser.version < 7; 

    if (!msie6) { 
    var top = $('#comment').offset().top - parseFloat($('#comment').css('margin-top').replace(/auto/, 0)); 
    $(window).scroll(function (event) { 
    // what the y position of the scroll is 
    var y = $(this).scrollTop(); 

    // whether that's below the form 
    if (y >= top) { 
    // if so, ad the fixed class 
    $('#comment').addClass('fixed'); 
    } else { 
    // otherwise remove it 
    $('#comment').removeClass('fixed'); 
    } 
}); 

}
});

回答

0
$('#comment').css({'overflow-y':'scroll', max-height:'100%'}); 
0

如果你指的是评论应该只浮动的范围内(由它确定的高度),那么你可能想看看这篇文章: Fixed Floating Sidebar

请参阅奖金部分。