Pri*_*ome 29 css string truncate
如何将长文本放入固定宽度的列中,我只有一行文本空间?文本需要剪切到固定的宽度(比如100px),我想在最后添加点"...".像这样的东西例如:
给定字符串:
Some really long string that I need to fit in there!
Run Code Online (Sandbox Code Playgroud)
固定宽度列中的所需输出应为:
Some really long string...
Run Code Online (Sandbox Code Playgroud)
Gor*_*don 73
你可以单独用CSS做到这一点:
.box {
-o-text-overflow: ellipsis; /* Opera */
text-overflow: ellipsis; /* IE, Safari (WebKit) */
overflow:hidden; /* don't show excess chars */
white-space:nowrap; /* force single line */
width: 300px; /* fixed width */
}
Run Code Online (Sandbox Code Playgroud)
注意:您需要查看最新的浏览器支持.