Wrap a text within only two lines inside div

前端 未结 11 796

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

    Another simple and quick solution

    .giveMeEllipsis {
       overflow: hidden;
       text-overflow: ellipsis;
       display: -webkit-box;
       -webkit-box-orient: vertical;
       -webkit-line-clamp: N; /* number of lines to show */
       line-height: X;        /* fallback */
       max-height: X*N;       /* fallback */
    }
    

    The reference to the original question and answer is here

提交回复
热议问题