【问题标题】:Text overflow entire strings if part of the string is hidden?如果部分字符串被隐藏,文本会溢出整个字符串?
【发布时间】:2021-10-10 07:58:34
【问题描述】:

鉴于这两个电子邮件“Example@example.com”和“Blahblahblahblah@example.com”。在将它们都显示在表格中时,如果两封电子邮件都无法完全显示,那么它们将被完整地剪掉。所以“Example@example.com, Blahblahblahblah@ex...”应该被缩减为“Example@example.com, ...”

【问题讨论】:

    标签: javascript css sass


    【解决方案1】:

    你正在寻找text-overflow: ellipsis:

    div{
      width:300px;
      overflow:hidden;
      text-overflow:ellipsis;
      white-space:nowrap;
    }
    <div>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit
    </div>

    【讨论】:

    • 不完全是,我的意思是如果 adipiscing 有任何溢出,则字符串变为“Lorem ipsum dolor sit amet, consectetur...”
    • @Korsaurus 它为我显示“Lorem ipsum dolor sit amet, consectetur adi ...”。
    • 也许这会更清楚一点:鉴于这两个电子邮件“Example@example.com”和“Blahblahblahblah@example.com”。如果两封电子邮件都无法完全显示,则将它们都显示在表格中时,它们会被完整地剪掉。所以“Example@example.com, Blahblahblahblah@ex...”应该被缩减为“Example@example.com, ...”
    猜你喜欢
    • 2013-01-02
    • 2014-02-24
    • 2016-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-17
    相关资源
    最近更新 更多