css实现省略号

一、使用css实现

.slh {

width:200px;

display: block;

overflow: hidden;

white-space:nowrap;

-o-text-overflow:ellipsis;

text-overflow:ellipsis;}

优点:简单易用
缺点:如果设置 /*td, th, div { word-break: break-all; word-wrap: break-word; }*/
ie8+直接根据宽度将宽度截取。而不会显示省略号。
而且如果不规定高度。文本还会换行显示。
所以加一个样式
.height20{height:20px;}

posted @ 2014-11-30 11:17  虫虫~  阅读(567)  评论(0编辑  收藏  举报