一、单行文本溢出省略
.text {
width: 200px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
border: 1px solid yellowgreen;
}
二、多行文本溢出省略
2.1.基于高度截断
.text2 {
height: 40px;
line-height: 20px;
position: relative;
overflow: hidden;
border: 1px solid yellowgreen;
}
.text2::after {
content: '查看更多';
position: absolute;
bottom: 0;
right: 0;
padding: 0 10px 0 10px;
}
2.2.基于行数截断
.text3 {
width: 200px;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
word-break: break-all;
border: 1px solid yellowgreen;
}