demo
- 代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
div {
font-size: 15px;
}
.demo1,
.demo2 {
width: 150px;
background: #ccc;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.demo2::after {
content: '你';
opacity: 0;
}
.demo3 {
width: 145px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
p {
width: 400px;
text-overflow: ellipsis;
display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: 4; /* 第几行开始隐藏 */
-webkit-box-orient: vertical;
text-align: justify;
}
</style>
</head>
<body>
<div class="demo1">一二三四五六七八九十</div>
<div class="demo2">一二三四五六七八九十</div>
<div class="demo3">一二三四五六七八九十</div>
<p>
一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十
</p>
</body>
</html>
- 效果