I am trying to layout a table in CSS. The requirements are as follow: the first column expands as much as it can, and text in the first column is limited to one line of text, if more, there should be an ellipsis. The other columns take only the space they need to contain the text in them without wrapping (text-wrap: nowrap).
The table itself is 100% width.
I managed to have either a fixed size first column with ellipsis, or a variable size first column with no ellipsis, I can't find a way to have a variable sized columns with ellipsis. Is it achievable with CSS? I can use CSS 3 properties if required, but I would like to avoid the use of JS.
Markup:
<table class="table">
<tr>
<th>First</th>
<th class="no-wrap">Second</th>
</tr>
<tr>
<td class="expand-column">
Some long long text here
</td>
<td class="no-wrap">
Other text
</td>
</tr>
</table>
CSS:
.table, .expand-column {
width: 100%;
}
.no-wrap {
white-space: nowrap;
}