【问题标题】:Html/Css - Replacing single or many lines with dotsHtml/Css - 用点替换单行或多行
【发布时间】:2014-07-03 00:20:40
【问题描述】:

我创建了这个 jsfiddle,其中第一行的末尾被替换为点:

http://jsfiddle.net/U8DmL/4/

代码:

div#container {
    font-size:14px;
    line-height:14px;
    width:140px;
    height:100px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}

但是如果我想显示两行或多行文本怎么办?

并在最后用点替换第二行?

有人有想法吗? (可以使用 html/css 或 jquery 吗?)

【问题讨论】:

  • 我应该使用 .outerHeight() jquery-function 吗?

标签: jquery html css replace


【解决方案1】:

我用 jquery 更新了你的小提琴

看看有没有帮助

$(function(){
 var content = $("#container").html();
if((content.length > 50 )) {

$("#container").html(content.substring(0,50) + "...")
}

})

http://jsfiddle.net/U8DmL/6/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 2011-03-22
    • 2011-01-23
    • 2019-03-24
    • 1970-01-01
    • 2011-02-19
    相关资源
    最近更新 更多