I have a table with columns that have percentage widths. If the content within those cells exceeds that percentage width, I would like it to be truncated with an ellipsis.
According to CSS text-overflow in a table cell? I should use the max-width attribute, but according to How can I set the max-width of a table cell using percentages? I can't do it with percentages.
table {
width: 100%;
}
table td {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
table tr td:nth-of-type(1) {
width: 20%;
}
table tr td:nth-of-type(2) {
width: 30%;
}
table tr td:nth-of-type(3) {
width: 50%;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
How can I resolve this?