js多余的内容显示省略号
// 这个可以实现多行的,内容增多显示省略号
$(".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;声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: 获取json中数组的length
- 下一篇: Java循环判断数组中是否包含字符串
