8

Single line:

div {
 /* 单行溢出隐藏 */
    width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

Multi-line:

div {
/* 多行溢出隐藏 */
    width: 150px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

Note:

-webkit-line-clamp used to limit the number of lines of text displayed in a block element. In order to achieve this effect, it needs to combine other WebKit properties. Common binding properties:
display: -webkit-box ; Attributes that must be combined to display the object as an elastic box model.
-webkit-box-orient must be combined with attributes to set or retrieve the arrangement of the child elements of the telescopic box object.


雾岛听风
11.9k 声望8.6k 粉丝

丰富自己,胜过取悦别人。