Zeux Zeux - 1 year ago 44
HTML Question

Text wrap with fixed max-height

I need to have a box (div) with some text over multiple lines, and this box needs to have a fixed width and a fixed max height.

I'm using the

overflow: hidden;
Now my problem is that if the last line doesn't fit in the div max height it will get cut (cutting just half of the line for example). What I want to do in this case is not to show the last line, and display ellipsis in the last one

My problem is not inserting ellipsis in a single text line (using the
white-space: nowrap
property), the main problem is that the text gets cutted in the last line, ellipsis is not an issue because in last case I can use jQuery to insert it



text-overflow: ellipsis;

to the Div

EDIT: ok, not possible for now, not in a standardized way.

BUT, it's possible to achieve it with experimental webkit features (see this topic), or to do it with JS through the solution written by this guy, and hosted on github.