css td 溢出改为省略号

    <style>
        .table{
            table-layout: fixed;
            width:100%;
        }
        .td{
            width:100px;  
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        word-wrap: normal;
} table td { border:1px solid red; } </style>

第二种方式是用js直接截取字符串,在拼接三个点...;这样页面样式看上去也像是超出变成...

截取字符串的方法有很多钟,这里只举例一种:str=str.substring(0,i); // 取字符串的前i个字符;

想要了解更多截取字符串方法,推荐一篇文章 https://www.cnblogs.com/cuixiaohua/p/7373171.html

 备注: .table是整个表格的样式, .td是需要改变td长度溢出变省略号的样式。

posted on 2017-07-07 19:19  程序猿-alvin  阅读(1621)  评论(0编辑  收藏  举报

导航