CSS table column autowidth

前端 未结 4 1213
感情败类
感情败类 2020-12-02 07:45

Given the following how do i make my last column auto size to its content? (The last column should autosize-width to the content. Suppose i have only 1 li element it should

4条回答
  •  無奈伤痛
    2020-12-02 08:36

    The following will solve your problem:

    td.last {
        width: 1px;
        white-space: nowrap;
    }
    

    Flexible, Class-Based Solution

    And a more flexible solution is creating a .fitwidth class and applying that to any columns you want to ensure their contents are fit on one line:

    td.fitwidth {
        width: 1px;
        white-space: nowrap;
    }
    

    And then in your HTML:

    
        ID
        Description
        Status
        Notes
    
    

提交回复
热议问题