用 CSS 隐藏超出显示宽度的内容

<style type=”text/css”>
.textOverFlow {    
width:300px;    
overflow:hidden;     
text-overflow:ellipsis;    
white-space:nowrap;    
border:1px solid #ddd;
}
</style>

<div>
测试内容
</div>

(1)指定宽度:width:300px;
(2)overflow:hidden;  将超出内容隐藏
(3)text-overflow:ellipsis; IE 专有属性,当对象内文本溢出时显示省略标记(…)
(4)white-space:nowrap; 强制在同一行内显示所有文本,直到文本结束或者遭遇 br 对象。

前一篇:Linux Shell编程入门
后一篇:Cacti实现短信报警

评论

太好了,沙发还是空的,要抢占

发表评论

可以使用下列 XHTML 标签:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>