如果不希望文本在多行分割,加white-space:nowrap
规则。 然后,为单元格设置一个max-width
。
对于图标,position
他们在absolute
右侧,z-index
高于文本。您还必须将relative
位置添加到包含的单元格中。 为了让它们在文本上可见,我添加了一个背景颜色(和一些左边的填充)。
编辑:修正了Mozilla的
的Mozilla似乎忽略position:relative;
的td元素。 要修复它,你来包装另一个DIV中的TD的内容,并运用这种风格
.tables td {
font-weight: 400;
font-size: 13px;
border-bottom: 1px solid #E1E1E1;
line-height: 38px;
text-align: right;
white-space: nowrap;
max-width: 200px; /* just an example */
}
.tables td > div {
overflow: hidden;
width:100%;
position: relative;
}
.linkFunctions {
display: none;
padding-top: 14px;
position: absolute;
right: 0;
z-index: 999;
background-color: #FFF9DC;
padding-left: 3px;
width: 100%;
max-width: 120px; /* just an example */
text-overflow: ellipsis;
overflow: hidden;
}
感谢GionaF!这很好用! :) – 99tharun
如果我们需要添加三个不要(...),只要我们缩短文本? – 99tharun
将此添加到。linkFunctions'width:100%; max-width:120px; text-overflow:ellipsis; 溢出:隐藏;' – Giona