html - jquery数据表中每列的最大宽度
问题描述
桌子
<div class="row">
<div class="col-lg-6">
<table id="datatable" class="table table-bordered dt-responsive nowrap" style="border-collapse:
collapse; border-spacing: 0; width: 100%;">
<thead>
<tr>
<th>Sr. No.</th>
<th>Product</th>
<th>Status Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Product 1</td>
<td>Description</td>
</tr>
....
</tbody>
</table>
</div>
</div>
我想减小Product列的宽度,它应该是固定大小的,如果其中的数据长度增加,它不应该增加。
我试过在 th 中使用width="20%"但它只影响默认宽度。我也试过:
$('#datatable').dataTable( {
"columnDefs": [
{ "width": "20%", "targets": 0 }
]
} );
但它也会改变默认宽度,但如果在 td 中插入更长的数据,它会增加。
此外,状态描述中的数据出现在一行中,有时会出现在页面之外,我如何才能保持该状态不变,以便数据显示在多行中。
我的目标是减少产品列的宽度,以便状态描述列可以显示在与产品相同的行中。
解决方案
推荐阅读
- r - R中的固定效应序数回归
- javascript - 如何在 dart 中使用 javascript 库?
- syntax - AHK在这里做什么?我做错了什么?
- java - AWS aurora RDS 中根用户的 IAM 权限
- javascript - 设置从前一页传递的struts2中文本字段的值
- shell - 如何在后台运行 screen 命令并将数据记录到日志文件?
- python - 如何从给定的模型中获取 Graph(或 GraphDef)?
- javascript - 全局更新函数中变量的值,以便下一次映射迭代具有 ReactJs 中的更新值
- java - 将代码作为 .jar 运行时出现 groovy.lang.missingMethodException
- ios - 如何使用 iOS SDK 删除 Google Maps 路线折线?