我有一个标签需要添加省略号,但是我无法实现:
<label id="div2">This is some long text that will not fit in the box</label>
label#div2 {
white-space: nowrap;
width: 30px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;
}
inline-block
:label#cats {
white-space: nowrap;
width: 30px;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;
display: inline-block;
}
jsFiddle: http://jsfiddle.net/rdg221bx/1/
display: block
或者inline-block
才能生效,因为标签默认是内联元素,省略号只对块级元素有效。 - Harry