1. 单行省略
.ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
2. 双行省略(webkit 内核)
.ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
}
3. 通用省略
.ellipsis {
position: relative;
line-height: 1.4em;
height: 2.8em;
overflow: hidden;
}
.ellipsis::after {
content: "...";
position: absolute;
bottom: 0;
right: 0;
padding: 0 5px 1px 30px;
background: linear-gradient(to right, rgba(255, 255, 255, 0), #ffffff 50%) repeat
scroll 0 0 rgba(0, 0, 0, 0);
}
![点击并拖拽以移动]()