关于firefox不支持text-overflow:ellipsis;的解决办法

原理等同于svg文件解决css3图片高斯模糊在火狐下不被支持的方法。

 

 

text-overflow:clip/ellipsis; 

前者clip是默认值,即“不显示省略标记,只是简单的裁切”;

后者ellipsis意思是“对象内文本溢出时显示省略标记(...)”。

 

 

但是当使用了text-overflow:ellipsis;以后,在ie下显示是正确的,超出部分为省略号...,而在firefox中超出部分却是裁切掉了,这是因为firefox不支持text-overflow:ellipsis;属性。

 

解决办法如下:(例子如下)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
*{
font-size:12px;
padding:0;
margin:0;
}

.main_leftlist a{
width:180px;
padding:0 0 0 5px;
display: block;
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
-moz-binding: url('ellipsis.xml#ellipsis');

}

</style>
</head>

 

<body> 

<table width="30%" cellspacing="0" class="club01_tab">
      <tbody>

        <tr> 
          <td><div class="main_leftlist"><a href="#">图说中国少年儿童百科全书-下卷</a></div></td>

         </tr>

        <tr> 
          <td><div class="main_leftlist"><a href="#">图说中国少年儿童百科全书-下卷</a></div></td>

         </tr>

        <tr> 
          <td><div class="main_leftlist"><a href="#">图说中国少年儿童百科全书-下卷</a></div></td>

         </tr>

     </tbody>

 </table>

</body>

 

注明:

url('ellipsis.xml#ellipsis');(注意路径)引用的是外部名为ellipsis.xml的文件,这是个固定写法。

 

 

ellipsis.xml文件的内容为:

 

<?xml version="1.0"?>
<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:window><xul:description crop="end" xbl:inherits="value=xbl:text"><children/></xul:description></xul:window></content></binding></bindings>

转载于:https://www.cnblogs.com/zhp404/articles/4172355.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值