单行文本
<selector>{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
多行文本
私有属性
p{
background-color: #f9e9cd;
overflow:hidden;
display: -webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:5;
}
双重伪元素
p{
overflow: hidden;
position: relative;
background-color: #f9e9cd;
text-align: justify;
padding-right: 1rem
}
p::before{
position:absolute;
content: "...";
right: 0;
bottom: 0;
}
p::after{
content: "";
position:absolute;
width: 1rem;
height: 1rem;
background-color:red;
right: 0;
display: inline;
margin-top: .5rem
}
linear-gradient
p{
overflow: hidden;
text-align: justify;
position: relative;
}
p::after{
content: "";
position:absolute;
height: 1.2rem;
width: 20%;
background:linear-gradient(to right, rgba(255,255,255,0), skyblue 80%);
right: 0;
bottom: 0;
margin-bottom: .2rem
}