用CSS 实现文本的单行和多行溢出省略效果

本文分解用CSS 实现文本的单行和多行溢出省略效果

用CSS 实现文本的单行和多行溢出省略效果

css源码:

//1:单行文本溢出
.textTruncate {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

//2:按行数-多行文本溢出(兼容性不好)
.mulLineTruncate {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
//3:按高度-多行文本溢出(没有省略号)
.mulLineTruncate {
max-height: 40px;
overflow: hidden;
line-height: 20px;
}
//4:解决3方案没有省略号的情况
.mulLineTruncate {
position: relative;
max-height: 40px;
overflow: hidden;
line-height: 20px;
&::after {
position: absolute;
right: 0;
bottom: 0;
padding: 0 20px 0 10px;
content: '...';
}
}

你学费了吗?

声明

⚠️免责声明:本站的资源均来自于用户投稿,作个人学习使用,其版权均归原作者所有。

⚠️侵权声明:如有侵权请私信:“管理员”反馈,我们将尽快处理。

⚠️转载声明:若需转载,请保留原文链接并附出处,谢谢合作。

个人中心
优惠劵
今日签到
有新私信 私信列表