TG:Note

作者: iambabewin | 来源:发表于2018-01-19 22:28 被阅读0次

    PC端实现首页新闻简介溢出隐藏:

     $(function() {
            $(".newsHidden").each(function() {
                var maxwidth = 58;
                if ($(this).text().length > maxwidth) {
                    $(this).text($(this).text().substring(0, maxwidth));
                    $(this).html($(this).html() + '...');
                }
            });
        })
    <p class="newsHidden">取得由中华人民共和国国家版权局颁发的计算机软件著作权登记证书。</p>
    
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp:2;
    overflow: hidden; /*换行,超出两行隐藏超出部分,并以'...'显示*/
    word-break:break-all; /*允许在单词内换行*/
    

    省略CSS处理

    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
    

    修复img跟着p同时移了2em问题:
    $(document).ready(function () {
    $('p img').parent().css('text-indent','0em');
    });

    相关文章

      网友评论

          本文标题:TG:Note

          本文链接:https://www.haomeiwen.com/subject/gvnaoxtx.html