CSS Table with one column taking remaining space

前端 未结 6 955
北荒
北荒 2020-12-16 13:04

I have tried now several things (and looked around here) and nothing worked so far. So I am going to ask.

What I want:

I have the following

6条回答
  •  自闭症患者
    2020-12-16 13:19

    See this fiddle (or, alternatively), you need to set the max-width for each table cell:

    body{
        width:100%;
        padding:0;
        margin:0;
    }
    table {
        margin-top: 50px;
        width:100%;
        max-width:100%;
    }
    table td {
        white-space: nowrap;
    }
    table td:nth-child(1) {
        background-color:red;
        max-width:100px;
    }
    table td:nth-child(2) {
        background-color: green;
        overflow:hidden;
        max-width:100px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    table td:nth-child(3) {
        background-color: orange;
        max-width:100px;
    }
    

提交回复
热议问题