2013-04-09 111 views
7

我有一个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;工作?

谢谢!

回答

11

white-space: nowrap;是你需要我相信。

+0

谢谢...这正是我想要的。 – 2013-04-09 16:31:23

相关问题