一开始,我只想让一段测试用的英文文字两端对齐就好了,这个不难:
如果加上中文这种表意文字,我们还得加一句:
text-justify:inter-ideograph;
如果是Web2.0,你就要小心用户连着写100个a作回复,把你的版面撑坏掉:
text-justify:inter-ideograph;
word-wrap:break-word;
word-break:break-all;
overflow: hidden;
好了,IE一切正常了,但在Firefox下看看,哈哈,什么作用也没有,Google之:
text-justify:inter-ideograph;
word-wrap:break-word;
word-break:break-all;
overflow: hidden;
-moz-binding: url('./wordwrap.xml#wordwrap');
在CSS文件目录下,加入一个wordwrap.xml文件,内容如下:
<bindings xmlns = “http://www.mozilla.org/xbl” xmlns:html = “http://www.w3.org/1999/xhtml”>
<binding id = “wordwrap” applyauthorstyles = "false">
//<![CDATA[
var elem = this;
elem.addEventListener('overflow',
function()
{
var exp = /<\/*[\s="'\w]+>/g;
var txt = elem.innerHTML;
var chars = txt.split('');
var newTxt = chars.join('');
newTxt = newTxt.replace(exp, reconstructTag);
elem.innerHTML = newTxt;
},false);
function reconstructTag(tag)
{
return _tag.replace(//g, '');
}
//]]>
最后,打个包给所有看日志都坚持到底的朋友:
[file]/attachment/2008/2008-05-23/wordwrap.zip[/file]
已知问题:
如附件示例,如果一个链接刚好在右边界,那在显示结果中会了现链接的html代码。