Compatible with Firefox, Chrome, IE6, IE7, IE8's new line of writing HTML

This link : https://java-er.com/blog/html-break-line-firefox-chrome/

Compatible Firefox, the Chrome , IE6, IE7, IE8 line of HTML writing transducer
1. arbitrary data automatically force a line

<div id=”ff” style=”border: 1px solid #f00; width: 300px; word-wrap: break-word;”>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
<script type=”text/javascript”>// <![CDATA[

function toBreakWord(intLen){
var obj=document.getElementById(“ff”);
var strContent=obj.innerHTML;
var strTemp=””;
while(strContent.length>intLen){
strTemp+=strContent.substr(0,intLen)+”
“;
strContent=strContent.substr(intLen,strContent.length);
}
strTemp+=”
“+strContent;
obj.innerHTML=strTemp;
}
if(document.getElementById && !document.all) toBreakWord(37)
// ]]></script>

This method for automatically taken by the word. The disadvantage is that if such a word can be change behavior hello
##### of He
the LLO

2.pre tag
<pre> </ pre>
inner wrap

Write the CSS
<pre> {pre
White-Space: pre-wrap; / * *. 3-CSS /
White-Space: -moz-pre-wrap; / * the Mozilla, since1999 * /
White-Space: -pre-wrap; / Opera4-6 * * /
White-Space: -o-pre-wrap; / * * Opera7 /
Word-wrap: BREAK-Word; / InternetExplorer5.5 * + * /} </ pre>
3. the CSS  force an inner element SUMMARY wrap
word-break: break-all; / * mandatory line * /
Word-BREAK: Keep-All; / * * not wrap force /

Is not compatible with some browsers this method

 


This entry was posted in  WEB前端 and tagged  . Bookmark the  permalink.
Small monthly rise QQ 2651044202, technical exchange QQ group 178,491,360

Starting address: May a small rise in blog  -  https://java-er.com/blog/html-break-line-firefox-chrome/
Unless otherwise noted, articles are original small rise in January, welcome to reprint, please indicate this article address, thank you

Guess you like

Origin www.cnblogs.com/wl-centrinc/p/12068471.html