css实现:
width:210px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
js实现:
function stringSub(s, len){
var l = 0;
var a = s.split("");
var subst = '';
for (var i = 0; i < a.length; i++) {
if (a[i].charCodeAt(0) < 299) {
l++;
} else {
l += 2;
}
subst += a[i];
if (l / 2 > len) {
subst += '...';
break;
}
}
return subst;
}