CSS table td width - fixed, not flexible

后端 未结 8 1703
温柔的废话
温柔的废话 2020-12-12 19:55

I have a table and I want to set a fixed width of 30px on the td\'s. the problem is that when the text in the td is too long, the td is stretched out wider than 30px.

相关标签:
8条回答
  • 2020-12-12 20:16

    Chrome 37. for non fixed table:

    td {
        width: 30px;
        max-width: 30px;
        overflow: hidden;
    }
    

    first two important! else - its flow away!

    0 讨论(0)
  • 2020-12-12 20:20

    you also can try to use that:

    table {
        table-layout:fixed;
    }
    table td {
        width: 30px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    

    http://www.w3schools.com/cssref/pr_tab_table-layout.asp

    0 讨论(0)
提交回复
热议问题