Maison  >  Article  >  interface Web  >  text-overflow截取字符串简单介绍_html/css_WEB-ITnose

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

WBOY
WBOYoriginal
2016-06-24 11:30:171259parcourir

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/

 

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn