2024年04月21日 建站教程
如何利用css实现文本的单行溢出省略和多行溢出省略,下面web建站小编给大家详细介绍一下具体实现代码!
单行溢出省略
div {
width:300px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
多行溢出省略
//按照行数省略
div {
width:300px;
display:-webkit-box;
text-overflow:ellipsis;
-webkit-line-clamp:2; /*控制行数*/
/*! autoprefixer: ignore next */
-webkit-box-orient: vertical;
overflow: hidden;
}
//按高度省略
div {
position: relative;
width:300px;
max-height: 40px;
overflow: hidden;
line-height: 20px;
}
div::after {
content: '...';
position: absolute;
right: 0;
bottom: 0;
}
本文链接:http://so.lmcjl.com/news/2735/