|
@@ -212,10 +212,15 @@
|
|
|
var count = $('#list-tbody tr').length;
|
|
|
let headerTop = $('#list-thead').offset().top; //获取表格头到文档顶部的距离
|
|
|
$(window).scroll(function () {
|
|
|
- if (count > 3 && (headerTop - $(window).scrollTop()) < 0) { //超过了
|
|
|
- //$('#list-thead').addClass('table-header-fixed'); //添加样式,固定住表头
|
|
|
+ if (count > 3 && (headerTop - $(window).scrollTop()) < 100) { //超过了
|
|
|
+ $('#list-thead').addClass('table-header-fixed'); //添加样式,固定住表头
|
|
|
+
|
|
|
+ $('#list-thead th').each(function (k, v) {
|
|
|
+ var width = $('#list-tbody td').eq(k).width() + 1;
|
|
|
+ $(v).width(width);
|
|
|
+ });
|
|
|
} else { //没超过
|
|
|
- //$('#list-thead').removeClass('table-header-fixed'); //移除样式
|
|
|
+ $('#list-thead').removeClass('table-header-fixed'); //移除样式
|
|
|
}
|
|
|
});
|
|
|
}
|