Wrap a text within only two lines inside div

前端 未结 11 805

I want to wrap a text within only two lines inside div of specific width. If text goes beyond the length of two lines then I want to show elipses. Is there a way to do that

11条回答
  •  忘掉有多难
    2020-12-04 09:40

    See http://jsfiddle.net/SWcCt/.

    Just set a line-height the half of height:

    line-height:20px;
    height:40px;
    

    Of course, in order to make text-overflow: ellipsis work you also need:

    overflow:hidden;
    white-space: pre;
    

提交回复
热议问题