在网页设计的时候,我们总会遇到一些现实文章内容简介的地方,如果内容简介特别字多的时候,我们需要省略标记,下面就介绍用css怎样实现这个功能。
text-overflow
CSS 中编写如下:
<style type="text/css">
.test_demo_clip{text-overflow:clip; overflow:hidden; white-space:nowrap; width:200px; background:#ccc;}
.test_demo_ellipsis{text-overflow:ellipsis; overflow:hidden; white-space:nowrap; width:200px; background:#ccc;}
</style>
BODY中编写如下:
<div class="test_demo_clip">
不显示省略标记,而是简单的裁切条
</div>
<div class="test_demo_ellipsis">
当对象内文本溢出时显示省略标记
</div>
网友评论