程序员人生 网站导航

IE与FF实现纯英文纯数字字符自动换行

栏目:htmlcss时间:2014-02-22 12:41:41

IE与FF实现纯英文纯数字字符自动换行

来源:http://www.heiniuhaha.cn/blog/?p=1112

IE css code:

#test{
width:135px;
table-layout:fixed;
word-break: break-all;
overflow:hidden;
}

FF js code:

<!Doctype html>
<html>
<body>
<div id="test" style=";border-width:1px;border-color:#333;width:400px;word-wrap:break-word;">
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
777777777777777777777777777777777777777777779999999999999999990000000000000000
</div>
<SCRIPT>
function toBreakWord(intLen){
var obj=document.getElementById("test");
var strContent = obj.innerHTML;
var strTemp = "";
while(strContent.length>intLen){
strTemp += strContent.substr(0,intLen)+"<br/>";
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+=strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById && !document.all){toBreakWord(20);}
</SCRIPT>
</body>
</html>
------分隔线----------------------------
------分隔线----------------------------

最新技术推荐