My table has a 100% width, and some of the td elements have overflow hidden. I want to make their text appear as ellipsis when it's too long.
I can achieve this with fixed td sizes, but I need them to be relative to the content.
This question was first posted 3 years ago on Stack Overflow: CSS: 100% width table, with cells that have hidden overflow and irregular/minimal cell widths
There haven't been any responses yet, so I'm wondering if it's possible now.
Here is an example on jsFiddle: https://jsfiddle.net/gd1fogee/
Below is a snippet:
table{
width:100%;
}
td{
/*max-width: 150px !important; */
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
padding: 3px 5px;
}
<div style="width:400px;display:block;">
<table>
<tr>
<td>one</td><td>two</td><td>three</td>
</tr>
<tr>
<td>this is a very very long text to show what i want to achieve</td><td>two</td><td>three</td>
</tr>
</table>
</div>
Thank you in advance for your assistance!