一直以来我都以为css是无法限制字符长度的,最近才发现原来可以这样.最简单的兼容方法:
.textOverflow { width:100px; white-space:nowrap;/*限制单行输出*/ text-overflow:ellipsis;/*只支持IE6(+)*/ overflow: hidden; -o-text-overflow: ellipsis;/*Opera专用*/ -moz-binding: url('ov.xml#ellipsis');/*firefox下实现要配套对应的xml文件*/ } /*.xul是为<xul:description>添加的class属性*/ .xul{ color:#fff; }
html代码:
<div class="textOverflow">块级元素块级元素块级元素块级元素块级元素块级元素</div>
根目录下ov.xml文件代码:
<?xml version="1.0" encoding="utf-8"?> <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <binding id="ellipsis"> <content> <xul:description class="xul" crop="end" xbl:inherits="value=xbl:text"><children/></xul:description> </content> </binding> </bindings>
现在网上很多是流行js方法来兼容ff的,其实上述介绍的是用了xul:description的方法,^_^我也不知道那是啥来的,不过这样写很简洁。
关于xul的教程《XUL教程》
转载请注明:作者Joe 地址:http://xiebiji.com/2008/11/textoverflow
:
昨天服务器被攻击了。。
: logo写错了,应该是:http://www.fanxipeng.com/logo.gif
: 我又来了
,昨天贵站怎么上去呀。
另外,我的LOGO做好了:http://www.fanxipeng.com
: 新的一年 新的气象 祝福你!!!
:
新年快乐~
期待你自制的主题 :roll:
joe Reply:
十二月 2nd, 2008 at 09:18
:oops: 第一次做可能要很久才做出来