Datatables force width table

给你一囗甜甜゛ 提交于 2020-01-25 03:55:32

问题


How can you force the width of a datatable ? Link to datatable example

I tried creating a table with a fixed width 350px and had a left column using 20% of width and the datatable in the right column. This doesn't work though as the datatable is pushing table to be bigger than 350px wide and also the left column is smaller than 20%

<table width="350">
<tr>
    <td width="20%"> Left TD <td>
    <td width="80%"> Datatable </td>
</tr>
</table>

回答1:


Use width in percentage for example

<table width="100%">
<tr>
    <td width="20%"> Left TD <td>
    <td width="80%"> Datatable </td>
</tr>
</table>



回答2:


<table width="350px" border="1">
<tr>
    <td width="20%"> Left TD <td>
    <td width="80%"> Datatable </td>
</tr>
</table>

use of width="350px" and the border="1" is going to make it look good. try this




回答3:


The problem is the select elements in the footer, set this and adjust to your needs

CSS

select{
    width: 100%;
}

DEMO HERE




回答4:


you'd better use css to customise your table, and deal with width, max-width, min-width,... also notice that datatable applies stylesheet to your table. You can see what is affected by doing a right click on your table header and click "inspect element" (you have this option in most of the navigators). See this post wich should answer your question : CSS: Truncate table cells, but fit as much as possible



来源:https://stackoverflow.com/questions/30074910/datatables-force-width-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!