<style>
.div1 {
width: 200px;
height: 200px;
background: red url(img/user.png) no-repeat;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.div1:hover {
overflow: visible;
text-overflow: inherit;
} </style>
<div class="div1">
qwe Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae voluptatem sapiente fuga facere molestias numquam officiis beatae ex sit atque aspernatur quisquam commodi ratione perspiciatis ducimus dolor minima itaque obcaecati!
</div>
CSS实现单行、多行文本溢出显示省略号
方法一:只显示3行,在第三行结尾显示...
p{display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: ;
overflow: hidden;
}
方法二:适用性更广,未超出部分也会出现...
p{
position: relative;
line-height: 20px;
max-height: 40px; /*是行高的整数倍,防止下行文字露出*/
overflow: hidden;
} p::after{
content: "..."; position: absolute; bottom: ; right: ; padding-left: 40px;
background: -webkit-linear-gradient(left, transparent, #fff %);
background: -o-linear-gradient(right, transparent, #fff %);
background: -moz-linear-gradient(right, transparent, #fff %);
background: linear-gradient(to right, transparent, #fff %);
}