Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TD width - the minimum needed using CSS

Consider this table:

<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>

How can I make the 3rd column to take the minimum width (depending on its content) and the 4th column to take the rest?

like image 667
GuyB7 Avatar asked Apr 25 '13 11:04

GuyB7


1 Answers

Use this

td:nth-child(3){
    background:red;
    width: 1px;
    white-space: nowrap;
}

DEMO

like image 175
Sowmya Avatar answered Sep 28 '22 07:09

Sowmya