CSS教程:text-overflow-ellipsis效果全兼容(无hack无js)

在看具体实例之前,我们先来看看实现原理

思路:
我们要达到的效果是:当“字符超过额定宽度”,则“显示三个小点”。
=> 当“字符超过额定宽度”,对于页面来说可能发生的一个改变就是:换行!
=> 换行将导致该范围的底线降低。
=> 那么,我们的目的则可以换算成:该范围的底线降低时显示三个小点

好了,以下是全部代码.大家可以直接复制修改使用.

<!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>
<title>无hack无js全兼容text-overflow-ellipsis效果-www.web2bar.cn</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style>
* { margin:0; padding:0;}
body { background:#fff;}
.list ul { font-size:12px; font-family:simsun; text-align:left; line-height:18px;}
.list a { color:#000; text-decoration:none; word-break:break-all;}
.list div { position:relative; zoom:1; padding-left:1em; background:url(/articleimg/2009/03/6494/ico.gif) no-repeat 3px 6px;}
.list span { position:absolute; right:-10px; bottom:0; height:18px; width:10px; background:#fff; overflow:hidden;}
.list li { position:relative; width:11em; background:url(/articleimg/2009/03/6494/pot.gif) right top no-repeat; height:18px; overflow:hidden; padding-right:10px; zoom:1;}
.list a:hover { color:#f60;}
</style>
<body>
<div class="list">
<ul>
<li>
<div>
<a href="#nogo">该标签中字符超过十个了</a>
<span></span>
</div>
</li>
<li>
<div>
<a href="#nogo">只有六个汉字</a>
<span></span>
</div>
</li>
<li>
<div>
<a href="#nogo">该标签中字符超过三十个了该标签中字符超过三十个了该标签中字符超过三十个了该标签中字符超过三十个了</a>
<span></span>
</div>
</li>
<li>
<div>
<a href="#nogo">blueidea blueidea blueidea</a>
<span></span>
</div>
</li>
</ul>
</div>
</body>
</html>

英文句子和连续字母/数字测试效果在非IE下欠佳(因为不自动换行),可以配合js来完善。有好的建议或意见,请多多指教。