一.在td的长度范围内要显示大量内容时,为了不破坏布局,只能显示该长度的文字,超过的的文字隐藏。 1.table 表中一定要设置 style="table-layout: fixed;" <table id="contentTable" class="table table-striped table-bordered table-condensed" style="table-layout: fixed;">
2.在td 中设置:style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis"
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis" onmousemove="removeClassType(this)">
3.鼠标进入悬浮显示,其实就是将内容赋值给标题属性。
onmousemove:鼠标进入事件
<td style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis" onmousemove="removeClassType(this)">
js:将td内的内容赋值给 title:标题内容
function removeClassType($this) {
$($this).attr("title",$this.innerText);
}
本文介绍了一种在TD中处理长文本的显示方法,通过设置CSS样式和使用JavaScript,实现文本溢出时的自动隐藏及鼠标悬停显示完整内容的功能。
1450

被折叠的 条评论
为什么被折叠?



