CSS:如何使用"..."限制显示的文本

Jas*_*son 11 html css web-applications trim

可能重复:
是否可以使用javascript或css实现overflow:省略号的效果?
如何使用CSS将长文本指定到较小的固定列中?

我希望修剪文本,如果它大于300px宽,带"......"

例如,如果我有:

<ul>
<li>this is greater than 300px, than only display as much of the text that is 300px wide and then replace the remaining text with "..."</li>
<li>short, don't trim</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

将显示为:

this is greater than 300px, than only ...
short, don't trim
|----------- 300px wide ----------------|
Run Code Online (Sandbox Code Playgroud)

我如何用CSS/HTML做到这一点?

归档时间:

查看次数:

73388 次

最近记录:

15 年,4 月 前