with
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
"..." will be shown in the end of the line if overflowed. However, this will be shown only in one line. But I would like it to be shown in multi-lines.
It may looks like:
+--------------------+
|abcde feg hij dkjd|
|dsji jdia js ajid s|
|jdis ajid dheu d ...|/*Here it's overflowed, so "..." is shown. */
+--------------------+
The link below provides a pure HTML / CSS solution to this problem.
Browser support - as stated in the article:
http://www.mobify.com/dev/multiline-ellipsis-in-pure-css
the css:
the html:
the fiddle
(resize browser's window for testing)
Just want to add to this question for completeness sake.
javascript solution will be better
is-ellipsis
class if the window resize or elment changegetRowRects
Element.getClientRects()
works like thiseach rects in the same row has the same
top
value, so find out the rects with differenttop
value, like thisfloat
...more
like this
detect window resize or element changed
like this
see more click here
I found a javascript trick, but you have to use the length of the string. Lets say you want 3 lines of width 250px, you can calculate the length per line i.e.
After looking over the W3 spec for text-overflow, I don't think this is possible using only CSS. Ellipsis is a new-ish property, so it probably hasn't received much usage or feedback as of yet.
However, this guy appears to have asked a similar (or identical) question, and someone was able to come up with a nice jQuery solution. You can demo the solution here: http://jsfiddle.net/MPkSF/
If javascript is not an option, I think you may be out of luck...