我在TailwindCSS中使用truncate
来在文本溢出超过一行时进行文本省略,但它不起作用。
我的代码不工作如下:
<div className="ml-1 inline-block">
<span>Label: </span>
<span className="font-semibold truncate">
long texttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
</span>
</div>
我该如何补救
1条答案
按热度按时间piztneat1#
首先,你的父元素或元素必须有一个特定的宽度,否则元素如何知道何时停止和截断?另外,为了截断工作,你的元素的显示不能显示
inline
,因为span
在默认情况下是内联显示的,你应该将其更改为block