[CSS备忘]多行文本省略号

        overflow : hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;    
        text-overflow: -o-ellipsis-lastline;

jquery写法:

$(".figcaption").each(function(i){
    var divH = $(this).height();
    var $p = $("p", $(this)).eq(0);
    while ($p.outerHeight() > divH) {
        $p.text($p.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."));
    };
});

 

posted @ 2014-02-27 17:01  joya  阅读(184)  评论(0编辑  收藏  举报