方式一:简单粗暴
显示前十个字符,后面的是省略号
{{ user_info.username | truncate(10) }}
方式二:老老实实写 css && js
css样式:
.slb{ text-overflow: ellipsis; white-space: nowrap; overflow: hidden; width: 80px; }
html页面:
<tr> <td class="user_defined slb"> <span style="text-align: center" onmouseout="miss(this)" onmousemove="appear(this)" ondblclick="add_check(this)">{{ info.username.0 }}</span> <span hidden>{{ info.uid }}</span> <span hidden>{{ info.profit }}</span> </td> </tr>
下面是js
function appear(ths) { $(ths).parent().removeClass(‘slb‘) } function miss(ths) { var has_class = $(ths).parent().hasClass(‘slb‘); if (has_class){ $(ths).parent().removeClass() }else { $(ths).parent().addClass(‘slb‘) } }
原文:http://www.cnblogs.com/mosson/p/6272755.html