用XBL实现FireFox连续字符自动换行
一般来讲,在排版中,中文及一些亚洲国家的文字标点不会在每行的起始位置显示,一个完整的英文单词不会出现在两行中,因此当连续的文字过长是会破坏所在区域的布局;IE下有word-break和word-warp来解决这个方法,但是Firefox不支持这两属性,用XBL能让Firefox达到相应的效果
XBLeXtensible Bindings Language也即是可扩展绑定语言,有点类似IE的HTC,HTC在CSS中的引用格式为:
p{behavior:url(test.htc)}主要作用就是用来定义XUL组件的行为模式,XBL语法结构为:
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl">
<binding id="binding1">
<!-- content, property, method and event descriptions go here -->
</binding>
<binding id="binding2">
<!-- content, property, method and event descriptions go here -->
</binding>
</bindings>
然后就可以通过Firefox的私有属性-moz-binding 将一个元素关联到一个XBL文件中的指定项上:
p {
-moz-binding:(url('lefter.net/demo/wordwrap.xml.xml#wordwrap');
}
Firefox演示效果推荐阅读 回家在自己的电脑上升级Firefox到Firefox/3.5.2,发现Firefox/3.5.2已经对word-breakz支持了,对text-shadow也已经支持了。

Give lefter a comment