[英]Using Thymeleaf to set column widths in a table
我有一个表格,其中第一列的宽度是固定的,其余列的宽度将平均占用剩余的速度。 问题是列是使用th:each
生成的,列数会有所不同。
如何将第一列设置为固定宽度,并在未知数量的列之间平均划分剩余空间?
<thead>
<tr>
<th style="width: 25%">
Fixed width
</th>
<th th:each="instance: ${headers}">
Dynamic width
</th>
</tr>
</thead>
您可以像这样计算宽度:
<thead th:with="fixed_width=25, dynamic_width=${(100 - fixed_width) / (#lists.size(headers) - 1)}">
<tr>
<th th:each="instance, status: ${headers}" th:style="|width: ${status.first ? fixed_width : dynamic_width}%|">
Dynamic width
</th>
</tr>
</thead>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.