Heim  >  Artikel  >  Web-Frontend  >  text-overflow截取字符串简单介绍_html/css_WEB-ITnose

text-overflow截取字符串简单介绍_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:30:171256Durchsuche

text-overflow截取字符串简单介绍:
使用css可以实现截取字符串的功能,主要就是采用text-overflow属性,当然单独使用该属性也是不能够实现此功能的,还是要配合其他属性使用,代码实例如下:

 

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">div{  width:150px;  height:20px;  overflow:hidden;  white-space:nowrap;  text-overflow:ellipsis;}</style></head><body><div>蚂蚁部落欢迎您,只有努力才会有没有好的明天</div></body></html>

 

以上代码实现了我们的要求,能够截取指定字符串,并且超出的部分以省略号替代。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=12919

更多内容可以参阅:http://www.softwhy.com/divcss/

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn