我按照这个和这个帖子来锁定第一列的宽度。表格是响应式的,我想在调整表格大小时实现第一列的固定宽度。我尝试了 Guruprasad 的帖子,但它不起作用。
html
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Number</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
<th>Table heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>First</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>Second</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
<tr>
<td>Third</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
</tbody>
</table>
</div>
css
.table>thead:first-child>tr:first-child>th:first-child
{
position: absolute;
display: inline-block;
height:100%;
}
.table> tbody > tr > td:first-child
{
position: absolute;
display: inline-block;
height:100%;
}
.table>thead:first-child>tr:first-child>th:nth-child(2)
{
padding-left:40px;
}
.table> tbody > tr > td:nth-child(2)
{
padding-left:50px !important;
}