CSS:如何使用“...”限制显示的文本[复制]

时间:2022-11-29 10:59:58

Possible Duplicates:
Is it possible to implement the effect of overflow:ellipsis with javascript or css?
How do I indicate long text into a smaller fixed column with CSS?

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

I want to trim text if it's greater than 300px wide with "..."

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

For example, if I had:

例如,如果我有:

<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>

Would display as:

将显示为:

this is greater than 300px, than only ...
short, don't trim
|----------- 300px wide ----------------|

How would I do that with CSS/HTML?

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

2 个解决方案

#1


11  

Using ellipsis in html

在html中使用省略号

#2


3  

Sorry all, I just found the answer here --> How do I indicate long text into a smaller fixed column with CSS?

对不起,我刚刚在这里找到了答案 - >如何使用CSS将长文本指示到较小的固定列中?

#1


11  

Using ellipsis in html

在html中使用省略号

#2


3  

Sorry all, I just found the answer here --> How do I indicate long text into a smaller fixed column with CSS?

对不起,我刚刚在这里找到了答案 - >如何使用CSS将长文本指示到较小的固定列中?