如果不希望文本在多行分割,加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