1,让框里的东西不换行,多了的自动加...
<DIV STYLE="width: 130px; border: 1px solid blue;
overflow: hidden; text-overflow:ellipsis">
<NOBR>meizz 测试 test 测试 test 测试 test 测试 test 测试.</NOBR></DIV>
2,js截取字符串长度
String.prototype.sub = function(n)
{
var r = /[^\x00-\xff]/g;
if(this.replace(r, "mm").length <= n) return this;
n = n - 3;
var m = Math.floor(n/2);
for(var i=m; i<this.length; i++)
{
if(this.substr(0, i).replace(r, "mm").length>=n)
{
return this.substr(0, i) +"...";
}
}
return this;
};
用法:var a = "gdfghrtfhrjtyjtukyukyk";a.sub(10);