td 内容超长截断处理

 

将 td里面的内容超过一定的长度时,将后面的内容省略,并用省略号表示

 

 

<html>
    <head>
    </head>
    <body>
        <table width="200px" style="table-layout: fixed" border=2px
            height="30px">
            <tr>
                <td
                    style="width: 100px; height: 20px; overflow: hidden; white- space: nowrap; text-overflow: ellipsis; word-break: keep-all">
                    中国人不得了中国人不得了中国人不得了中国人中国人不得了中国人不得 了中国人不得了中国人
                </td>
            </tr>
        </table>

        <table style="table-layout: fixed">
            <tr>
                <td>
                    <span
                        style="width: 300px; overflow: hidden; text- overflow: ellipsis; white-space: nowrap; word-break: keep-all;">
                        aaaaaaaaaaaaaaaaaaafewwwwwwwwwwwwwwwwwwaaaaaaaaafdsfdsaaaaaaafsdfaaaaa

                        aaafdsssssssssss </span>
                </td>
            </tr>
        </table>
    </body>
</html>

 

转载于:https://www.cnblogs.com/yehancheng/p/3172879.html

THE END
< <上一篇
下一篇>>