我有一个<span>
标签,,里面.lastMessageLink
有一个, 。可以放入的文本可以短到几个字符,也可以长到一个段落,但我想显示最多 4 行文本。<a>
.lastMessageText
.lastMessageText
我目前的样式不起作用,是这样的:
.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 取得进展。