首先设定3个关键样式,指定样式后,超长文本就会显示省略号了
/* 文本超长class */
.textEllipsis{
color:red;/*颜色*/
overflow: hidden;/*不允许滚动条*/
white-space: nowrap;/*不允许文本换行*/
text-overflow: ellipsis;/*文本超长显示省略号*/
}
鼠标移上去显示全文有两种方法:
1、把全部文本写在div的title属性里面
/* 在列的formatter参数中指定该函数,把全文放入title里面*/
function contentFormat(value, row, index){
if(value){
return "<div title='"+value+"' class='textEllipsis'>"+value+"</div>";
}else{
return '';
}
}
2、在原来样式的基础上再写一个鼠标移上去的样式,去掉省略号
/* 鼠标移上,显示全文class */
.textEllipsis:hover {
height: auto;
word-break:break-all;
white-space: pre-wrap;
text-decoration: none;
}