使用 text-overflow: ellipsis
.text {
overflow: hidden; /* 将超出的部分隐藏掉 */
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
Title
不使用 text-overflow: ellipsis
.brief-wrap {
display: flex;
width: 800px;
}
.brief-wrap .brief {
font-size: 24px;
line-height: 44px;
height: auto;
max-height: 140px;
overflow: hidden; /* 将超出的部分隐藏掉 */
position: relative;
}
.brief-wrap .brief::before {
width: 1px;
content: "";
height: calc(100% - 44px);
float: right;
right: 0;
}
.brief-wrap .brief::after {
content: "";
width: 90px;
height: 44px;
position: absolute;
background: #101010;
}
.brief-wrap .brief .btn {
float: right !important;
clear: both;
width: 90px;
font-size: 24px;
line-height: 44px;
box-sizing: border-box;
border-radius: 4px;
color: #fff;
cursor: pointer;
border: 0;
text-align: right;
}
.brief-wrap .brief .btn::after {
content: "...展开"; /*采用content生成*/
}
.brief-wrap .checkbox {
position: absolute;
/*visibility: hidden;*/
}
.brief-wrap .checkbox:checked + .brief {
max-height: fit-content;
}
.brief-wrap .checkbox:checked + .brief .btn::after {
content: "收起";
}