IE与FF实现纯英文纯数字字符自动换行
来源:http://www.heiniuhaha.cn/blog/?p=1112
IE css code:
#test{ width:135px; table-layout:fixed; word-break: break-all; overflow:hidden; } |
<!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> |