当表头冻结使用CSS时,表头和正文没有正确对齐
问题描述:
我有一个表格的以下格式,当我试图修复它的头使用下面的CSS,我失去对齐方式,表头和正文没有得到正确对齐。我可以做什么来克服这个问题。
I have a table of the following format when i m trying to fix its head using the following css, I m losing the alignment , the table header and body are not getting aligned properly..What can I do to overcome this..
#ex_table
{
table-layout: fixed !important;
}
#ex_table thead tr
{
position: fixed !important;
}
这里是HTML部分
<div class="table_div" style="height:400px;width:98%;overflow:scroll">
<table id="ex_table">
/*thead and tbody populated dynamically via jquery datatables*/
<tfoot id="ex_footer">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
答
/ p>
You got to set width to your cells strictly:
th,td {
width:30px
}
th, td { width:30px }