Reputation: 89
I am using datatables from here. I have made a table from my database. I want to change width of each column in terms of percentage. Any relative code or example can help me?
<table id="example" cellspacing="0" width="100%">
<thead>
<tr>
<th width="60%">Name</th>
<th width="40%">Position</th>
</tr>
</thead>
<tbody>
<tr>
<td width="60%">ABC</td>
<td width="40%">DEF</td>
</tr>
<tr>
<td width="60%">XYZ</td>
<td width="40%">ZYX</td>
</tr>
</tbody>
</table>
Upvotes: 1
Views: 630
Reputation: 1156
According to their documentation you can do the following:
$('#example').dataTable( {
"columns": [
{ "width": "60%" },
{ "width": "40%" },
]
});
Upvotes: 1