Limit text length to n lines using CSS

后端 未结 13 983
滥情空心
滥情空心 2020-11-22 02:53

Is it possible to limit a text length to \"n\" lines using CSS (or cut it when overflows vertically).

text-overflow: ellipsis; only works for 1 line tex

13条回答
  •  既然无缘
    2020-11-22 03:07

    .class{
       word-break: break-word;
       overflow: hidden;
       text-overflow: ellipsis;
       display: -webkit-box;
       line-height: 16px; /* fallback */
       max-height: 32px; /* fallback */
       -webkit-line-clamp: 2; /* number of lines to show */
       -webkit-box-orient: vertical;
    }
    

提交回复
热议问题