css3实现多行文字截断处理
Sunny-117 opened this issue · comments
<!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>
.text-container {
width: 200px;
overflow: hidden;
}
.multiline-text {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="text-container">
<p class="multiline-text">
This is a long text that needs to be truncated if it exceeds multiple lines.
</p>
</div>
</body>
</html>