Wrap a text within only two lines inside div

前端 未结 11 743

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:23

    @Asiddeen bn Muhammad's solution worked for me with a little modification to the css

        .text {
     line-height: 1.5;
      height: 6em; 
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
     }
    

提交回复
热议问题