有一张宽桌子,上面有table-layout: fixed。我试图弄清楚该width: min-content属性应如何适用于该表的单元格。
table {
table-layout: fixed;
width: 100%;
border: 1px solid #000;
border-collapse: collapse;
}
th,
td {
border: 1px solid #000;
}
.min {
width: min-content;
}Run Code Online (Sandbox Code Playgroud)
<table>
<thead>
<tr>
<th class="min">Col1</th>
<th>Col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>X</td>
<td>Y</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
我在 Firefox 中得到了想要的结果,但在 Chrome 中却没有得到。这是 Chrome 的错误还是我做错了什么?
如果这是 Chrome 的错误,那么考虑到我想使用table-layout: fixed并且不想查找像这样的固定单元格宽度,那么获取第一列的最小宽度的解决方法是什么width: 30px?