0

My basic ellipsis style and mark-up is as follows (fiddle):

.ellipsis{
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
<table>
<tbody>
<tr>
    <td>Row Start (1)</td>
    <td class="ellipsis">Lectus ligula uspendisse tiam per sodales feugiat tempus ante pede vitae amet conubia raesent tincidunt n feugiat id ad mi dapibus</td>
    <td>Row End</td>
</tr>
<tr>
    <td>Row Start (2)</td>
    <td class="ellipsis">Placerat consectetuer inceptos dictum mollis adipiscing placerat sed tincidunt ullam id onec lectus sagittis consequat conubia tempus eleifend ad orbi risus hac dolor accumsan commodo a eros ed consectetuer odio feugiat dignissim dictum at ullam ligula mollis sollicitudin rutrum viverra in feugiat conubia metus uspendisse sit non imperdiet unc liquam</td>
    <td>Row End</td>
</tr>
</tbody>
</table>

... but it just makes my table stretch to fit everything in a single line and document gets a nice horizontal scroll. Same code works as expected for non-table block-level elements.

Is there a workaround that doesn't force me to use fixed widths?

Álvaro González
  • 142,137
  • 41
  • 261
  • 360

2 Answers2

0

http://jsbin.com/jehaxequ/1/edit

TD max width is a solution here. If you don't know the max width of td, the problem isn't easy to do with CSS, however a little jquery or javascript can be used to calculate the max width of td, and add it "live" to your element properties.

Jacek Kowalewski
  • 2,761
  • 2
  • 23
  • 36
0

Add a max-width property.

JSBIN

painotpi
  • 6,894
  • 1
  • 37
  • 70