<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>多行省略 尾随按钮</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.wrap {
display: flex;
}
.text {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-all;
padding: 0 10px;
}
.text::before {
float: right;
content: '';
background-color: red;
/* 减去尾随按钮高度 */
height: calc(100% - 21px);
}
.more {
float: right;
clear: both;
line-height: 17px;
height: 21px;
}
</style>
</head>
<body>
<div id="app">
<div class="wrap">
<div class="text">
<button class="more">更多</button>
你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜你猜
</div>
</div>
</div>
</body>
</html>
页面多行时最后会有一个展开按钮和省略号共存
最新推荐文章于 2023-07-18 10:38:31 发布