有固定的thead时,是否可以动画无限滚动到tbody?

时间:2016-01-11 03:28:51

标签: jquery jquery-animate

我正在使用一个小UI来展示比赛终结者。该计划将信息拉入表格,以帮助保持一切顺利。

function scrolling() {
  $('#scrollup table').animate({
  top: '-=' + $('#scrollup table tr:last').height()
},
1000,
'linear',
function() {
  var offset = $('#scrollup table tr:last').offset().top;
  console.log(offset);
  if (offset <= 1352) {
    $('#scrollup table').css("top", 0);
    $('#scrollup table tr:last').after($('#scrollup table tr:first').detach());
  }
}
  );}
$(document).ready(function() {
  setInterval('scrolling()', 1000)
});

我不确定如何保持thead固定并保持平滑滚动。 Demo

1 个答案:

答案 0 :(得分:0)

<强> DEMO

只需将以下样式添加到thead

即可
thead{
  position:fixed;
  background:gray;
}

并且在动画中detach tr时,只有detach tbody的{​​{1}}。

tr