如何固定一行中的字符数,然后显示三个点(例如“某些文本...”)
示例:
|Name | Age |Description |
+-------+---------+----------------------+
|Alice | 34 | abcderh zyz...|
+-------+---------+----------------------+
|Robert La... | 34 | Sometext is...|
如果您能够分析 "Sometext is..."
和 is/La
之后的 ,它会显示三个点而不是完整字符/字符串。
如何对单个列以及所有列执行此操作。
我在 Google 上进行了很多尝试,但仍然找不到有关此问题的任何有用的教程。
我的代码:
$(document).ready(function() {
$('#example').dataTable();
} );
我已经尝试了所有这些链接:
jQuery DataTable overflow and text-wrapping issues
jQuery DataTables issue: columns and rows not in one line
但这一切都没有解决我的问题。请帮助我。
最佳答案
您需要text-overflow: ellipsis;
或text-overflow: "...";
设置在您的 css
中:
td{
text-overflow: ellipsis; // this is producing "..."
white-space: nowrap;
overflow: hidden;
}
或者更多上下文:
#example td{
text-overflow: ellipsis; // this is producing "..."
white-space: nowrap;
overflow: hidden;
}
Docs for text-overflow @ MDN
关于javascript - 数据表行中的固定字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23736219/