不超出宽度显示一行且居中,超出一行未满两行不显示省略号,超出一行满两行显示省略号

 $('#js-list .enlist-list-name').each(function () {
            var listNameContent =  $(this).html(),
                listNameLength = listNameContent.length; 

            if (listNameLength > 5) {
                $(this).addClass('more-breaking active-list-name');
            } else {
                $(this).removeClass('more-breaking active-list-name');
            }
   })
.active-list-name {
    line-height: .5rem;
    width: 55%;
    height: 100%;
}
.more-breaking {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.enlist-list-name {
    width: 55%;
    height: 100%;
    line-height: .96rem;
}
<p class="enlist-list-name fr more-breaking active-list-name">愛新覺羅伊梓</p>





猜你喜欢

转载自blog.csdn.net/like_jack/article/details/80405813