2011-04-21 82 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

請參閱獎金部分。