能通过CSS实现pre的效果吗

html-css012

能通过CSS实现pre的效果吗,第1张

pre{

white-space: pre-wrap!important

word-wrap: break-word!important

*white-space:normal!important

}

css pre加了 强制换行怎么不可以

比如,指定宽度为200px换行代码:

overflow: visible

width:200px

word-wrap:break-word

white-space:-moz-pre-wrap

针对IE7的强制换行代码:

word-wrap:break-word

针对火狐的强制换行代码:

white-space:-moz-pre-wrap

<script>

function toBreakWord(intLen){

var obj=document.getElementById("ff")

var strContent=obj.innerHTML

var strTemp=""

while(strContent.length>intLen){

strTemp+=strContent.substr(0,intLen)+"<br>"

strContent=strContent.substr(intLen,strContent.length)

}

strTemp+="<br>"+strContent

obj.innerHTML=strTemp

}

if(document.getElementById &&!document.all) toBreakWord(37)

</script>