CSS截取字符串,多余文字省略号显示

html-css010

CSS截取字符串,多余文字省略号显示,第1张

小气鬼的楼主,连一分都不给...但正好有时间,我来帮你注释吧.

<style type="text/css">

body{

font-family:Arial, Helvetica, sans-serif/* 字体种类*/

font-size:12px/*字体大小*/

}

div{

width:200px/*容器宽度*/

height:24px/*高度*/

line-height:24px/*行高*/

overflow:hidden/*超出部分 隐藏*/

border:#ccc solid 1px/*容器边框,1像素,颜色是#ccc(淡灰)*/

background-color:#F9F9F9/*背景色*/

margin:5px/*上下左右全空5像素*/

}

div a{

color:#000/*链接颜色*/

display:block/*转化为区块*/

padding-right:7px/*右缩进7像素*/

background:url(http://www.365css.cn/example/ellipsis_365css.cn/ellipsis.gif) no-repeat right bottom/*背景图片,右下显示,只显示一次*/

}

</style>

<div><a href="#">CSS截取字符串,超出用省略号代替</a></div>

<div><a href="#">CSS截取字符串,并将超出用省略号代替</a></div>

<div><a href="http://www.hi.baidu.com/fzlibei" target="_blank">CSS</a></div>

<div><a href="http://www.hi.baidu.com/fzlibei" target="_blank"><span></span></a></div>

图呢?

css 只能改变文字样式 把文字隐藏

如 display:noneoverflow:hiddentext-indent:-9999px等等都可以把文字隐藏掉

你说的多出几个字 肯定是html中的代码有问题...不关css的事...

<table border="0">

<tr>

<td><div style="width:10pxheight:20pxoverflow:hidden">fffffffffffff<br>ffff</div></td>

</tr>

</table>这个应该可以达到你想要的那种效果