初始结果
自动添加省略号
源码
<!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>省略号</title>
<style>
.box1{
height: 40px;
width: 100px;
background-color:aqua;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.box2{
height: 40px;
width: 100px;
background-color:rgb(92, 138, 138);
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
单行省略号
<div class="box1">
我啥也不想说,此处省略一万字
</div>
<br/>
<hr>
<br/>
多行省略号(具体行数自定义)
<div class="box2">
我啥也不想说,此处省略一万字
</div>
</body>
</html>