CSS实现让的多余的文字出现省略号

我们在行列时,经常会出现一行文字超出了宽度,很多人使用了

 overflow:hidden  让超出来的内容隐藏,有没有一种代码让文字超出时,出现省略号了?

答案是有

使用:white-space:nowrap;text-overflow:ellipsis; -o-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>
div.wid
{ width:200px;white-space:nowrap;text-overflow:ellipsis; -o-text-overflow:ellipsis; overflow: hidden;}
</style>
</head>

<body>
<div class="wid"><a href="http://www.websjy.com/bbs/forumdisplay.php?fid=9" target="_blank">避免表格table和DIV被撑开变形的CSS代码实例</a></div>
</body>
</html>

 

 

posted @ 2010-08-15 18:22  设计源  阅读(743)  评论(8编辑  收藏  举报