Home  >  Article  >  Web Front-end  >  text-overflow截取字符串简单介绍_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:30:171259browse

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/

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn