在页脚Jquery处停止浮动

在页脚Jquery处停止浮动,jquery,html,css,Jquery,Html,Css,我正在使用这个代码: $(window).scroll(function () { if (($(document).height() - $(window).scrollTop()) <= 500){ $("#content-5").css({ position: 'fixed', top: 'auto', bottom: '300px' }); } else if ($(window).sc

我正在使用这个代码:

  $(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'
      });
  }
$(窗口)。滚动(函数(){
if(($(document.height()-$(window.scrollTop())=30){
$(“#内容-5”).css({
位置:'固定',
顶部:“30px”,
底部:“自动”
});
}否则{
$(“#内容-5”).css({
位置:'绝对',
顶部:“30px”,
底部:“自动”
});
}
}))

这是演示


它的工作很好,但我不知道怎么做,浮动元素不会停在页脚。有人能帮忙吗?

我已经更新了你的小提琴……将你的第一块css更改为

$(“#content-5”).css({
位置:'固定',
顶部:“0px”,
底部:“自动”
});


什么浮动元素??
#content-5
??页脚的哪一部分?我认为您需要使用
,而不是
$().css
。这是一个糟糕的工作固定div。它不停在页脚,但应该停止。您是否检查了我提供的
小提琴
。。。?如果是,那么你能解释一下你想要达到什么目标吗。。。?