简体   繁体   English

HTML表自动扩展最后一列以占用剩余宽度

[英]HTML table automatically expand last column to occupy remaining width

I have a table structure which looks like below; 我有一个表格结构,如下所示;

<table style="width: 100%; display: flex; flex-flow: column; table-layout: fixed">
<thead style="width: 100%">
<th style="width: 10%; min-width: 10rem">Col1</th>
<th style="width: 20%; min-width: 20rem">Col2</th>
<th style="width: 30%; min-width: 30rem">Col3</th>
<th>Col with no explicit width defined (I want this col to expand)</th>
</thead>
<tbody>
<tr>
<td>Col1</td>
<td>Col2</td>
<td>Col3</td>
<td>Col4</td>
</tr>
</tbody>
</table>

Now my simple question is I want the last column to have flexible width ie it should occupy whatever is the remaining width (depending on the screen resolution, etc) 现在我的简单问题是,我希望最后一列具有灵活的宽度,即它应该占据剩余的宽度(取决于屏幕分辨率等)

However, it seems to be taking only the required space and not automatically expanding to take rest of the space. 但是,它似乎仅占用所需的空间,而不会自动扩展以占用其余空间。 Is that something which is possible to do with the table layout ? 这与表格布局有关吗?

display: flex overwrites the tables default display mode display: table , which you need. display: flex覆盖表的默认显示模式display: table ,这是您需要的。 Remove it (and flex-flow: column; ). 删除它(以及flex-flow: column; )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM