我想用省略号类删除右侧的额外空格。
.ellipsis{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
}
div{
float:left;
}
.clear {
clear:both
}

<div class="ellipsis">hsdhhgasdhgasdgj</div><div>asdasd</div>
<div class="clear"></div>
<div class="ellipsis">asdasdasd</div><div>asdadsas</div>
&#13;
答案 0 :(得分:0)
答案 1 :(得分:0)
我认为你在寻找这个......
.ellipsis{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
float:left;
}
.clear {
clear:both
}
&#13;
<div class="ellipsis">hsdhhgasdhgasdgj</div><div>asdasd</div>
<div class="clear"></div>
<div class="ellipsis">asdasdasd</div><div>asdadsas</div>
&#13;
答案 2 :(得分:0)
这取决于font-size
和font-family
,在这种情况下,您应该将max-width:
设置为87px
答案 3 :(得分:0)
如何正确签署文本?
.ellipsis{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
text-align: right;
float: left;
}
.clear {
clear:both
}
<div class="ellipsis">hsdhhgasdhgasdgj</div><div>asdasd</div>
<div class="clear"></div>
<div class="ellipsis">asdasdasd</div><div>asdadsas</div>
答案 4 :(得分:0)
.ellipsis{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
}
div{
float:left;
}
.clear {
clear:both
}
<div class="ellipsis">hsdhhgasdihgasdgj</div><div>asdasd</div>
<div class="clear"></div>
<div class="ellipsis">asdasdasd</div><div>asdadsas</div>
ellipsis
之后将没有空格。它在文本中对char进行辩护。例如,尝试将文字更改为hsdhhgasdihgasdgj
并查看结果。
答案 5 :(得分:0)
我创建了一个类.space-off
,用margin-left
帮助删除了这个空格。 Here就是例子:
.ellipsis {
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
float:left;
}
.space-off {
margin-left: -6px;
}
div {
float:left;
}
.clear {
clear:both
}
<div class="ellipsis">hsdhhgasdhgasdgj</div>
<div class="space-off">asdasd</div>
<div class="clear"></div>
<div class="ellipsis">asdasdasd</div><div>asdadsas</div>
答案 6 :(得分:0)
for firefox而不是text-overflow: ellipsis;
使用text-overflow: ellipsis '...';
或text-overflow: clip '...';
对于Chrome它不起作用https://code.google.com/p/chromium/issues/detail?id=133700
所以使用我在forchrome
类中声明的支持两者的内容,或者首先检测浏览器并相应地显示html,如果你想使用文本溢出额外的属性。在forchrome
类只是改变是我写了margin-right:-1px
从字符串末尾移位1px
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
}
.elipdot {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis'...';
max-width: 90px;
}
.elipclip {
white-space: nowrap;
overflow: hidden;
text-overflow: clip'...';
max-width: 90px;
}
.forchrome {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100px;
border: 1px solid #930;
margin-right: -1px;
}
div {
float: left;
/** for debugging**/
border: 1px solid green;
}
.clear {
clear: both
}
<!-- previous code using default-->
<div class="ellipsis">hsdhhgasdhgasdgj</div>
<div>asdasd</div>
<div class="clear"></div>
<div class="ellipsis">asdasdasd</div>
<div>asdadsas</div>
<!-- will not work on chrome https://code.google.com/p/chromium/issues/detail?id=133700
<!-- using text-overflow: ellipsis '...'; -->
<div class="elipdot">hsdhhgasdhgasdgj</div>
<div>asdasd</div>
<div class="clear"></div>
<div class="elipdot">asdasdasd</div>
<div>asdadsas</div>
<!-- using text-overflow: clip '...'; -->
<div class="elipclip">hsdhhgasdhgasdgj</div>
<div>asdasd</div>
<div class="clear"></div>
<div class="elipclip">asdasdasd</div>
<div>asdadsas</div>
<!-- previous for chrome-->
<div class="forchrome">hsdhhgasdhgasdgj</div>
<div>asdasd</div>
<div class="clear"></div>
<div class="frochrome">asdasdasd</div>
<div>asdadsas</div>
答案 7 :(得分:0)
如果我理解你的要求你想要两行长度等于......
如果是这样,您可以将letter-spacing
属性添加到课程ellipsis
答案 8 :(得分:0)
尝试以下风格
.ellipsis {
text-overflow:clip;
max-width:100%;
}
让我知道它是否有用
答案 9 :(得分:-1)
您可以将margin-right: -5px
添加到您的elipsis类
.ellipsis{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 90px;
margin-right: -5px;
}
见工作Fiddle