Javascript 自下而上固定浮动边栏

Javascript 自下而上固定浮动边栏,javascript,Javascript,我一直在使用这个固定浮动侧边栏(http://jqueryfordesigners.com/fixed-floating-elements/). 这很好,我唯一的问题是我不知道如何强制底部出来,这样固定的位置将永远不会高于可视区域。我的侧边栏可以添加内容,有时当有很多内容时,侧边栏会从页面底部延伸出来。有人能朝正确的方向开枪吗?下面是侧边栏的javascript var msie6 = $.browser == 'msie' && $.browser.version <

我一直在使用这个固定浮动侧边栏(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');
  }
});
var msie6=$.browser=='msie'&&$.browser.version<7;
如果(!msie6){
var top=$('#comment').offset().top-parseFloat($('#comment').css('margin-top').replace(/auto/,0));
$(窗口)。滚动(功能(事件){
//卷轴的y位置是什么
var y=$(this.scrollTop();
//是否在表格下方
如果(y>=顶部){
//如果是的话,请选择固定类别
$('#comment').addClass('fixed');
}否则{
//否则,请将其移除
$('#comment').removeClass('fixed');
}
});
}
});

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