TD宽度 - 使用CSS所需的最小值

Guy*_*yB7 6 html css html-table width

考虑一下这个表:

<table style="width: 100%">
    <tr>
        <td>Static length</td>
        <td>Static length</td>
        <td><div>Length varies</div></td>
        <td>Space filler</td>
    </tr>
    <tr>
        ...
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

如何使第3列采用最小宽度(取决于其内容)和第4列采取其余的?

Sow*_*mya 9

用这个

td:nth-child(3){
    background:red;
    width: 1px;
    white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud)

DEMO

  • 作品!感谢您的演示 (2认同)