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;
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: html 隐藏多余字段,显示省略号
- 下一篇: Js 实现字数限制,超出部分显示为省略号