I searched stack overflow and looked at some solutions but nothing worked so far. What I have is a table with flexible column widths and one of the table cell has divs with some text that I want to have ellipses for overflow.
JS fiddle example here:
<table>
<td class= 'name'>Name</td>
<td class='desc'>
<div>
<div class='desc-1'>descript1:</div>
<div class='desc-2'>really long description that I want to have ellipses for ajhdfjhdf ajhdf akjdhf asdjfh askdjfh askdjfh asdkjfh askjdfh askdjfh askjdfhaksjdhf askjfdh ajkdsfh
</div>
</div>
</td>
</table>
.name {
width: 50%;
}
.desc {
width: 50%;
max-width: 100%;
}
td {
border: 1px solid black;
}
td div {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
If I set the width for the .desc
class to a fixed value, it works fine, like here:
.desc {
width: 50%;
max-width: 300px;
}
How to get it to work for flexible grid column width (percentage value)?
Edit: The solution here helped solve my problem: