Up to 2 lines of text can be displayed, and redundant ones will be omitted.

The front end can display up to 2 lines of text in CSS, you can use  overflow: hidden and  text-overflow: ellipsis attributes, and set a height limit.

For example:

.box { 
    overflow: hidden;
    text-overflow: ellipsis;
  // As long as it exceeds the width, it will wrap, no matter Chinese or English
    word-break: break-all;
 // display up to two lines
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
//According to the style setting
    line-height: 1.2em;
    max-height: 2.4em;
}

This way, if the text requires more lines to be fully displayed, the excess text is omitted and an ellipsis (...) appears at the end.

Guess you like

Origin blog.csdn.net/qq_43532275/article/details/129024124