【发布时间】:2014-06-11 12:58:47
【问题描述】:
我在 7 个月前曾发布过关于此问题的帖子,有人很友好地为我指出了正确的解决方案: bootstrap 3 responsive table with fixed first column
但是,这突然停止工作,固定列不再固定。 要查看它的实际效果,请访问:http://nasgame.apphb.com (示例数据:搜索 Matt Vincent 并选择 Pro)
第一列现在随着其余内容滚动。
这是操作代码:
jquery
$(function(){
var $table = $('.table');
//Make a clone of our table
var $fixedColumn = $table.clone().insertBefore($table).addClass('fixed-column');
//Remove everything except for first column
$fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();
//Match the height of the rows to that of the original table's
$fixedColumn.find('tr').each(function (i, elem) {
$(this).height($table.find('tr:eq(' + i + ')').height());
});
});
css
.table-responsive>.fixed-column {
position: absolute;
display: inline-block;
width: auto;
border-right: 1px solid #ddd;
}
@media(min-width:768px) {
.table-responsive>.fixed-column {
display: none;
}
}
【问题讨论】:
标签: jquery css twitter-bootstrap twitter-bootstrap-3