CSS文本省略号返回每个段落的第一行

3lxsmp7m  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(123)

我试图在文本上应用省略号,但它占用了所有段落的第一行。但是,我只需要内容的第一行。
样本内容

While sending message via websocket this code is triggered. However, '+ msg +' does not detect new lines (line breaks) in the message. Every sentence appears in the same line.

Optimize this jquery code so that '+ msg +' can detect new lines.

字符串
我得到了什么


的数据
我真正想要的



下面是我的CSS代码

.content .message {
  font-size: 0.8rem;
  color: #afb9d7;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}


HTML

<div class="content">
  <div class="name">Shreyansh Jha </div>
  <div class="message " data-msg="While sending message via websocket this code is triggered. However, '+ msg +' does not detect new lines (line breaks) in the message. Every sentence appears in the same line. <br />
    <br />
    Optimize this jquery code so that '+ msg +' can detect new lines.">While sending message via websocket this code is triggered. However, '+ msg +' does not detect new lines (line breaks) in the message. Every sentence appears in the same line. <br>
    <br>
    Optimize this jquery code so that '+ msg +' can detect new lines.
  </div>
</div>


我如何才能达到所需的输出?

i7uq4tfw

i7uq4tfw1#

文本省略号仅适用于单个长段落的宽度。
所以在这里,你必须删除<br />标签,如果可能的话,必须使用**\n**。否则,它将把它作为该部分/段落中的一个单独部分。
或者,你可以让它的高度固定,并从CSS的Angular 来管理它。

相关问题