当表头冻结使用CSS时,表头和正文没有正确对齐 [英] Table header and body are not getting aligned properly when table header freezed using CSS

查看:280
本文介绍了当表头冻结使用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 }

这篇关于当表头冻结使用CSS时,表头和正文没有正确对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆