//
这个可以实现多行的,内容增多显示省略号
$(".txt").each( function () {
if ($( this ).text().length > 20) {
$( this ).html($( this ).text().replace(/\s+/g, "").substr(0, 20) + "...")
}
$(".txt").each( function () {
if ($( this ).text().length > 20) {
$( this ).html($( this ).text().replace(/\s+/g, "").substr(0, 20) + "...")
}
})
上面是在jQuery中实现,
下面是在css中实现:
display: -webkit-box;
overflow: hidden;
white-space: normal !important;
text-overflow: ellipsis;
word-wrap: break-word;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
font-size: 16px;
font-weight: normal;
color: #434343;
margin-top: 8px;
height: 16px;