css如何设置td溢出隐藏


本文摘自PHP中文网,作者醉折花枝作酒筹,侵删。

方法:首先使用“word-break:keep-all”语句设置不换行;然后使用“overflow:hidden”语句设置超出隐藏部分;最后使用“text-overflow:ellipsis”语句设置溢出显示省略号。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

td溢出隐藏

1

2

3

4

5

6

7

8

9

10

11

table{

        width:100px;

        table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */

    }

    td{

        width:100%;

        word-break:keep-all;/* 不换行 */

        white-space:nowrap;/* 不换行 */

        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */

        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用*/

    }

全部代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>document</title>

<style>

table{

        width:100px;

        table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用。 */

    }

    td{

        width:100%;

        word-break:keep-all;/* 或是 white-space:nowrap;不换行 */

        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */

        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ;需与overflow:hidden;一起使用*/

    }

</style>

</head>

<body>

    <table border="1">

        <tr>

            <td>19999</td>

            <td>19999</td>

        </tr>

        <tr>

            <td>19999</td>

            <td>19999</td>

        </tr>

        <tr>

            <td>19999</td>

            <td>19999</td>

        </tr>

    </table>

</body>

</html>

效果截图:

阅读剩余部分

相关阅读 >>

不能忘却的悼念:将网页背景变为黑白色调教程

css怎么固定底部不动

css 中 @ 用法详解

css如何实现文字不能选中

css怎么实现图片居中

css怎么设置草书字体

css怎么设置边框线样式

css中如何定义使用变量

css中width什么意思

css怎样设置背景透明

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...