jquery数据表没有完全占据宽度

jquery datatable is not fully occupying the width

您好,我正在使用在页面中对齐的 Jquery 数据表(内部使用 bootstrap css)。生成的数据表没有完全占据页面的整个宽度。 Html 我正在使用的代码如下。

<table class="table table-hover table-nomargin table-striped table-bordered dataTable dataTable-scroll-x">
    <thead>
        <tr>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>

使用此 Jsfiddle 用户可以拖动列以查看其分离。: http://jsfiddle.net/rhkvhcnb/1/

SOLUTION

  • 删除autoWidth: false
  • width="100%" 属性添加到 <table>(jQuery DataTables 中可能存在宽度计算错误,我不得不使用 width="99.9%" 来解释 table边界)

DEMO

有关代码和演示,请参阅 this jsFiddle