多行和单行文本截取
/* 单行截取 */
div {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
/* 多行 */
/* 方法一(仅支持webkit内核浏览器) */
div {
/* 将对象作为弹性伸缩盒子模型显示 */
display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: 2;
/* 设置或检索伸缩盒对象的子元素的排列方式 */
-webkit-box-orient: vertical;
/* 设置是否用...显示 */
text-overflow: ellipsis;
}
/* 方法二(通过伪元素绝对定位到行尾并遮住文字,在通过overflow:hidden隐藏多余文字),文字短的时候有空白 */
p{
position: relative;
line-height: 18px;
height: 36px;
overflow: hidden;
/* word-break: break-all; */
}
p::after{
content: '...';
font-weight: bold;
position: absolute;
bottom: 0;
right: 0;
padding: 0 20px 1px 45px;
background: -webkit-linear-gradient(linear, left top, right top, from(tgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
padding: 0 20px 1px 45px;
background: -moz-linear-gradient(linear, left top, right top, from(tgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
padding: 0 20px 1px 45px;
background: -o-linear-gradient(linear, left top, right top, from(tgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
padding: 0 20px 1px 45px;
background: -ms-linear-gradient(linear, left top, right top, from(tgba(255, 255, 255, 0)), to(white), color-stop(50%, white));
background: linear-gradient(to right, rgba(255,255,255,0), white 50%, white)
}