我创建了这个 jsfiddle,其中第一行的末尾用点替换:
代码:
div#container {
font-size:14px;
line-height:14px;
width:140px;
height:100px;
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
但是如果我想显示两行或更多行文本怎么办?
然后把第二行末尾的点换掉?
有人知道吗? (可能与 html/css 或 jquery 一起使用?)
最佳答案
我用 jquery 更新了你的 fiddle
看看有没有帮助
$(function(){
var content = $("#container").html();
if((content.length > 50 )) {
$("#container").html(content.substring(0,50) + "...")
}
})
关于jquery - Html/Css - 用点替换单行或多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23663222/