当表格的列比较多时 横向列太拥挤 这时候需要自定义宽度 设置横向滚动条
1.html代码
<div id="tableArea">
<table id="table" class="display table table-bordered" cellspacing="0" >
<thead>
<tr>
<th style="display: none">ck</th>
<th>序号</th>
<th>账号</th>
<th>姓名</th>
<th>CPID</th>
<th>CP名称</th>
<th>操作</th>
</tr>
</thead>
</table>
</div>
#tableArea .dataTables_wrapper {
position: relative;
clear: both;
zoom: 1;
overflow-x: auto;
}
#tableArea table{
width: 800px;
}
这里的overflow-x:auto是新增的,表示表格内容超出宽度后,出现横向滚动条;table的width必须写死宽度,直接写在table元素上不生效,原因未知。