[英]how to truncate text in table-cell?
i want to make my table cell contenteditable like the one in excel (means when i click on any cell, a highlighted editable box should come and its width should grow if entered text exceeds the cell-width). 我想使表格单元格的内容可编辑,就像excel中的表格一样(意味着当我单击任何单元格时,应该出现一个突出显示的可编辑框,并且如果输入的文本超出单元格的宽度,则其宽度应增大)。 when i am done, table cell should be displayed as a normal cell but exceeding text should truncate. 完成后,表格单元格应显示为普通单元格,但超出文本的部分应截断。 It should be similar to excel sheet cell. 它应该类似于excel表格单元格。
i have tried, 我努力了,
<td contenteditable="true" class="content" style="overflow:hidden"></td>
and on focus event i made its z-index:15. 在焦点事件中,我将其z-index设置为:15。 Also on blur event, i removed the z-index. 同样在发生模糊事件时,我删除了z-index。 But the text entered is not trimmed and cell width gets updated as that of text. 但是输入的文本不会被修剪,像元一样会更新单元格宽度。
i also have tried, 我也尝试过
<td><div contenteditable="true" style="width:100%; height:100% overflow:hidden"></div>
</td>
but overflow not working. 但溢出无法正常工作。
please help and thanks in advance. 请帮助并提前致谢。
i think you expecting like this try this 我认为您期望像这样尝试
.content{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
and also try 并尝试
word-wrap: break-word;
overflow-wrap: break-word;
for breaking word. 破词。
.content:focus{
display: inline-block;
width: "YOUR WIDTH";
}
Now you should add question in javascript tag about : "how to make an edit in that cell" 现在,您应该在javascript标记中添加有关以下问题:“如何在该单元格中进行编辑”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.