admin管理员组

文章数量:1315118

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

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

Share Improve this question edited Apr 19, 2016 at 3:17 Chris Martin 30.8k12 gold badges80 silver badges140 bronze badges asked Oct 12, 2012 at 14:24 ZeuxZeux 3721 gold badge4 silver badges12 bronze badges 1
  • Try this link:stackoverflow./questions/3067696/… – dreamerkumar Commented Oct 12, 2012 at 14:26
Add a ment  | 

1 Answer 1

Reset to default 6

Add

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.

本文标签: javascriptText wrap with fixed maxheightStack Overflow