无法设置jquery的数据表插件10.1的数据表宽度

时间:2016-09-24 08:13:43

标签: jquery html css datatable

我在页面中有很多jQuery插件的数据表。对于某些数据表,它与页面匹配,但对于其他数据表,数据表的宽度比页面大。我尝试了很多没有成功的事情: html中的-set样式 - 使用数据表的这个功能

fnInitComplete : function() {
   $("#tableid").css("width","100%");
}

。使用这些方法,我无法正确设置它,也不知道如何做到这一点。

2 个答案:

答案 0 :(得分:0)

如果你的表列非常适合页面宽度,那么你可以使用datatable响应式插件示例在这里

https://datatables.net/extensions/responsive/examples/column-control/auto.html

如果表格列足以适合页面,那么如果您在表格标签中使用bootstrap add class,则会自动获取宽度。 对于前。

<table class="table">
   <thead>
   </thead>
   <tbody>
   </tbody>
</table>

使用css

max-width:100%

答案 1 :(得分:0)

只需将表格宽度设置为100%

<table width="100%">
       <thead>
       </thead>
       <tbody>
       </tbody>
 </table>