[英]Specify number of lines for href inside span tag
我有一個<span>
標記.lastMessageLink
,其中帶有一個<a>
.lastMessageText
。 可以放在.lastMessageText
的文本可以短至幾個字符,也可以長至一個段落,但是我想顯示最多4行文本。
我目前無法使用的樣式是這樣的:
.lastMessageLink {
line-height: 1em;
text-overflow: ellipsis;
max-height: 4em;
overflow: hidden;
}
.lastMessageText {
color: black;
word-wrap: break-word;
}
這是HTML:
<span class="lastMessageLink">
<a id="undefined" class="lastMessageText" title="now i need a really really long message so that i can test this whole multiple lines thing which is gonna be a problem and a trickier problem than we had initially thought. it's interesting because you'd think a couple css styles would be enough, but we might have to go by characters" href="#conversation:cid=10714&mid=10735">
now i need a really really long message so that i can test this whole multiple lines thing which is gonna be a problem and a trickier problem than we had initially thought. it's interesting because you'd think a couple css styles would be enough, but we might have to go by characters
</a>
</span>
我看過HTML / CSS:指定<span>內的行數 , 使用CSS 將文本長度限制為n行 , 使用CSS文本溢出來更改設置高度的元素內的文本行數 ,以及如何為固定數量的文本行設置元素高度 。
我對使用jQuery或Javascript的解決方案持開放態度,因為我無法僅憑CSS取得進步。
對網絡的研究以及一些以前的堆棧溢出問題 ( 也在此處 )表明,除非設置了white-space: nowrap
,否則ellipsis
將不起作用。 當然,這意味着它僅適用於一行文本 。
一些可能的JQuery插件可以補償:
三點 http://tpgblog.com/2009/12/21/threedots-the-jquery-ellipsis-plugin/
將<span>
更改為<div>
,這應該可以解決我的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.