【发布时间】:2016-12-16 03:03:06
【问题描述】:
所以我在一个 div 中有一个数据表,它应该进行宽度设置,而另一个数据表将它居中:
<div style='text-align:center !important'>
eakjflsdj
<div id="ajax_table_header" style="width: 60%;">
lbah
<table id="ajax_table">
<thead>
<tr>
<th>ID</th>
<th>Reference</th>
<th>Date</th>
<th>Title</th>
<th>Site</th>
<th>Location</th>
</tr>
</thead>
</table>
</div>
</div>
文本按预期居中,但是当我更改时
<div id="ajax_table_header" style="width: 60%;">
到
<div id="ajax_table_header" style="width: auto;">
好像没有应用 css。
当我<table id="ajax_table" style="width: auto"> 时,只有表格缩小到可管理的大小,而搜索栏、分页和其他所有内容继续延伸到 div 的边缘。
我可以做些什么来使其居中并自动调整大小?
Jsfiddle:https://jsfiddle.net/nc45tz0d/1/
在ajax_table_header 中摆弄display: table 之后似乎是解决方案
【问题讨论】:
标签: jquery css datatables