CCS3属性之text-overflow:ellipsis;的用法和注意之处

语法:

text-overflow:clip | ellipsis

默认值:clip

适用于:所有元素

clip: 当对象内文本溢出时不显示省略标记(...),而是将溢出的部分裁切掉。 
ellipsis: 当对象内文本溢出时显示省略标记(...)。

更多参考:http://hovertree.com/h/bjaf/pr_text-overflow.htm

在使用的时候,有时候发现不会出现省略标记效果,经过测试发现,使用ellipsis的时候,必须配合overflow:hidden; white-space:nowrap; width:200px;这三个样式共同使用才会有效果,示例代码:

<style type="text/css">
    .test{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;width:360px;}
</style>

<div class="test">欢迎光临<a href="http://hovertree.com/">何问起</a>! hovertree.com css3实现文本溢出显示省略号。<a href="http://hovertree.net/">Midi下载</a></div>

查看效果:http://hovertree.com/h/bjaf/1hg11eg4.htm

练习题:http://hovertree.com/tiku/bjaf/curs4a42.htm

web前端汇总:http://www.cnblogs.com/jihua/p/webfront.html

posted on 2016-03-01 14:47  计划  阅读(33303)  评论(0编辑  收藏  举报