字太多用...代替的方法(两种)

网友投稿 189 2023-06-02


字太多用...代替的方法(两种)

jquery方法:

$(function() {

$(".head-pic .user-name").each(function() {

var maxwidth = 4;

if ($(this).text().length > maxwidth) {

var b = $(this).children().is("a");

if (b) {

$(this).children().text($(this).children().text().substring(0, maxwidth) + "...");

} else {

$(this).text($(this).text().substring(0, maxwidth));

$(this).text($(this).text() + http://"..");

}

}

});

});

css方法LokKIZp:

overflow: hidden;

white-space:nowrap;

text-overflow:ellipsis; // IE

-o-text-overflow: ellipsis; //Opera

-icab-text-overflow: ellipsis; //iCab

-khtml-text-overflow: ellipsis; //Konqueror Safari

-moz-text-overflow: ellipsis; //Firefox,mhttp://ozilla

-webkit-text-overflow: ellipsis; //Safari,Swift

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持我们!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:详解java中保持compareTo和equals同步
下一篇:Spring MVC 4.1.3 + MyBatis零基础搭建Web开发框架(注解模式)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~