在页脚Jquery停止Float

时间:2014-07-27 11:12:05

标签: jquery html css

我正在使用此代码:

  $(window).scroll(function () {
  if (($(document).height() - $(window).scrollTop()) <= 500){
      $("#content-5").css({
          position: 'fixed',
          top: 'auto',
          bottom: '300px'
      });
  } else if ($(window).scrollTop() >= 30) {
      $("#content-5").css({
          position: 'fixed',
          top: '30px',
          bottom: 'auto'
      });
  }else{
      $("#content-5").css({
          position: 'absolute',
          top: '30px',
          bottom: 'auto'
      });
  }

});

这是演示

  

http://jsfiddle.net/Ym2Ga/75/

它的工作正常,但我不知道怎么办,那个浮动元素停在页脚。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

我已经更新了你的小提琴....改变你的第一块css ......

$("#content-5").css({ position: 'fixed', top: '0px', bottom: 'auto' });

fiiddle