1

I'm with a simple problem with text-overflow. I can ellipsis my text, but the text won't fill the div entirely.

Here's the demo in jsfiddle: Fiddle

I thought that this piece of code would do the trick but I'm wrong.

overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

I've seen various topics related like CSS text ellipsis when using variable width divs, Can't get "text-overflow: ellipsis;" to work, but none of them worked for me.

Community
  • 1
  • 1
Linesofcode
  • 5,327
  • 13
  • 62
  • 116

2 Answers2

0

Add width to the element for ellipsis to work. It works when content exceed the width of the container. It would not work without specifying the width of the container.

Ankur Mishra
  • 51
  • 1
  • 8
0

Try this

Jsfiddle: http://jsfiddle.net/manublueheart/D4FKm/3/

The trick is adding -webkit-box-orient: vertical; to your css

p.first{
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 16px;     /* fallback */
    max-height: 32px;      /* fallback */
}
Felipe Miosso
  • 7,309
  • 6
  • 44
  • 55
Manu
  • 806
  • 1
  • 9
  • 25