firefox(火狐)截取字符串用省略号代替

转自:http://zsp.javaeye.com/blog/261175

作者:zuroc,已经将程序打包,我只是把解压的代码转贴。

主要技术:xul

搜索原帖用关键词:firefox text-overflow:ellipsis

html文件如下:

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<style>

.ellipsis {

-o-text-overflow: ellipsis;

text-overflow: ellipsis;

-moz-binding: url('ellipsis.xml#ellipsis');

}

</style>

</head>

<body>

<div class="ellipsis" style="clear: both; white-space: nowrap; float: left; width: 115px; overflow: hidden; border: 1px solid #ccc;">

short

</div>

<div class="ellipsis" style="clear: both; white-space: nowrap; float: left; width: 215px; overflow: hidden; border: 1px solid #ccc;">

A very, very, very, very, very, very, very, very, very long text

</div>

</body>

</html>

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>

你可能感兴趣的:(firefox)