Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-overflow ellipsis without "white-space: nowrap"? [duplicate]

I was wondering if there is any clever way, to achieve the css ellipsis effect without the need to apply white-space: nowrap also.

In other words, lets say we have a block element of a certain height and we'd like to let it get filled up with text-content, but the ellipsis should get applied as soon as there is no more room in horizontal plus vertical directions.

Quick example: http://jsfiddle.net/fpv9n/2/

Text should be like it is, but also with an ellipsis at the end. Any way to achieve that using CSS ? I would take JS solutions also into consideration.

like image 894
jAndy Avatar asked Jun 10 '13 16:06

jAndy


People also ask

How do you overflow an ellipsis text?

To clip at the transition between characters you can specify text-overflow as an empty string, if that is supported in your target browsers: text-overflow: ''; . This keyword value will display an ellipsis ( '…' , U+2026 HORIZONTAL ELLIPSIS ) to represent clipped text.

Why text-overflow ellipsis does not work?

text-overflow: ellipsis only works when the following is true: The element's width must be constrained in px (pixels) – it doesn't work with values specified using % (percent.) The element must have following properties set: overflow: hidden and white-space: nowrap.

How do I fix text-overflow in CSS?

A text-overflow property in CSS is used to specify that some text has overflown and hidden from view. The white-space property must be set to nowrap and the overflow property must be set to hidden. The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string.


1 Answers

There is no way to do this using pure CSS. It's monstrous and sad. I've often desired this myself when you want the browser to "ellipsify" a multi-line text with possibly overflowing text whenever it spills out of the container.

like image 129
Bendoh Avatar answered Sep 22 '22 13:09

Bendoh