方法一:
设置css样式
tr td{
/* 下面是设置文本内容超出隐藏不换行的 */
word-break:keep-all;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
table{
table-layout:fixed;
}
方法二:
jq控制表格里的文字大小 超过隐藏 鼠标移上去提示
超过隐藏 判断长度
鼠标移上去提示 加标题title
var odiv= $("#odiv").html();
if(odiv.length > 5){
$("#odiv").attr("title",odiv);
$("#odiv").html(odiv.substring(0,5)+"...");
}else{
$("#odiv").html(odiv);
}
<table>
<tr>
<td><div id="odiv">这是是文字哦哦哦哦哦哦哦哦哦哦哦哦</div></td>
</tr>
</table>