【发布时间】:2013-04-09 16:20:43
【问题描述】:
我有一个带有 CSS 的 div:
div.c
{
font-size: 18px;
color: #888;
max-width: 300px;
display: inline-block;
overflow: hidden;
line-height: 20px;
text-overflow: ellipsis;
word-break: break-all;
}
The content in this div is "Abcdef abcdefabcdefabcdefabcdefaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" //for example, given only to show length in div.
但是如果使用上面的CSS,div 的内容会被破坏并且没有three dots //as of text-overflow: ellipsis;。如果我删除word-break: break-all;,那么将形成两行,第一行是第一个单词,第二行是第二个单词。但是text-overflow: ellipsis; 可以处理这个问题。
我该怎么做才能将所有文本保留在一行上并让text-overflow: ellpsis; 工作?
谢谢!
【问题讨论】: