我试图在文本上应用省略号,但它占用了所有段落的第一行。但是,我只需要内容的第一行。
样本内容
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>
型
我如何才能达到所需的输出?
1条答案
按热度按时间i7uq4tfw1#
文本省略号仅适用于单个长段落的宽度。
所以在这里,你必须删除
<br />
标签,如果可能的话,必须使用**\n**。否则,它将把它作为该部分/段落中的一个单独部分。或者,你可以让它的高度固定,并从CSS的Angular 来管理它。