Home  >  Article  >  Web Front-end  >  Force newline characters in Firefox based on javascript_javascript skills

Force newline characters in Firefox based on javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:25:021135browse

Effect demonstration code:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

CSS control forced line break/force Line break

Force no line break
div{
white-space:nowrap;
}

Automatic line break
div{
word-wrap: break- word;
word-break: normal;
}

Force English word line break
div{
word-break:break-all; }<script> 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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn