【问题标题】:Store text before text-overflow:elipsis?在文本溢出之前存储文本:省略号?
【发布时间】:2019-02-03 02:22:09
【问题描述】:

我有一个高度有限的容器,并且在 p -tag 中的内容很长,因此使用文本省略号和溢出。如何获取显示在省略号之前的最后一句话/单词或整个文本并存储它?

.grid-container > div > p {
    text-align: left;
    margin: 10px;
    -ms-hyphens: auto;
    -webkit-hyphens: auto;
    hyphens: auto;
    display: block; /* Fallback for non-webkit */
    display: -webkit-box;
    max-width: 700px;  
    max-height: 360px;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis-word;
} 

【问题讨论】:

  • 你打算如何存储它?这是唯一的 css 问题还是您打算为此使用 javascript?
  • @elitepc 对我来说都可以接受,即使我更喜欢仅使用 css 的解决方案。

标签: css string text overflow ellipsis


【解决方案1】:

刚刚发现了一个类似的问题,问的差不多,但没有省略号部分。这不完全是答案,但已经足够接近了:How to find the last visible word position in a text container?

【讨论】:

    猜你喜欢
    • 2018-07-22
    • 1970-01-01
    • 2013-04-01
    • 2017-01-21
    • 2019-04-29
    • 2019-03-06
    • 1970-01-01
    • 1970-01-01
    • 2016-10-18
    相关资源
    最近更新 更多