[size=large]
转自:http://blog.csdn.net/dannywj1371/article/details/8127778
先给贴代码:
01 <p style="width: 300px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
02 省略我吧!
03 省略我吧!
04 省略我吧!
05 省略我吧!
06 省略我吧!
07 省略我吧!
08 省略我吧!
09 省略我吧!
10 省略我吧!
11 省略我吧!
12 省略我吧!
13 省略我吧!
14 </p>
测试浏览器: IE6/7/8/9、opera12.02、firefox15.0.1、chrome21.0.1180.89 m
完整例子:http://www.ostools.net
现在解释一下为什么要这样做:
1、text-overflow: ellipsis;
这里的重点样式是 text-overflow: ellipsis;
不过话说text-ellipsis是一个特殊的样式,有关解释是这样的:text-overflow属性仅是注解,当文本溢出时是否显示省略标记。并不具备其它的样式属性定义。要实现溢出时产生省略号的效果还须定义:强制文本在一行内显示(white-space:nowrap)及溢出内容为隐藏(
转自:http://blog.csdn.net/dannywj1371/article/details/8127778
先给贴代码:
01 <p style="width: 300px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
02 省略我吧!
03 省略我吧!
04 省略我吧!
05 省略我吧!
06 省略我吧!
07 省略我吧!
08 省略我吧!
09 省略我吧!
10 省略我吧!
11 省略我吧!
12 省略我吧!
13 省略我吧!
14 </p>
测试浏览器: IE6/7/8/9、opera12.02、firefox15.0.1、chrome21.0.1180.89 m
完整例子:http://www.ostools.net
现在解释一下为什么要这样做:
1、text-overflow: ellipsis;
这里的重点样式是 text-overflow: ellipsis;
不过话说text-ellipsis是一个特殊的样式,有关解释是这样的:text-overflow属性仅是注解,当文本溢出时是否显示省略标记。并不具备其它的样式属性定义。要实现溢出时产生省略号的效果还须定义:强制文本在一行内显示(white-space:nowrap)及溢出内容为隐藏(