I have a table:
table {
width: 100%;
border: 1px solid grey;
border-collapse: collapse;
}
th, td {
text-align: left;
border: 1px solid grey;
padding: 5px;
}
.rest-of-width {
background: red;
}
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th class="rest-of-width">Notes</th>
</tr>
<tr>
<td>1</td>
<td>Foo bar baz</td>
<td>This column should take up the rest of the space</td>
</tr>
<tr>
<td>2</td>
<td>Foo</td>
<td>Bar</td>
</tr>
</table>
I've set its width to 100% and all the columns inside the table auto-size to total 100% as expected.
However, I'd like all columns to size as if the table width was auto, except the column with the class rest-of-width
on it, which should take up the remaining space.
A bit like this flexbox example:
.wrapper {
display: flex;
border: 1px solid grey;
}
.wrapper__a,
.wrapper__b,
.wrapper__c {
padding: 5px;
border: 1px solid grey;
}
.wrapper__c {
flex: 1;
background: red;
}
<div class="wrapper">
<div class="wrapper__a">Id</div>
<div class="wrapper__b">Name</div>
<div class="wrapper__c">Notes</div>
</div>
Is this possible using a CSS property?