Table with table-layout: fixed; and how to make one column wider

后端 未结 4 1695
甜味超标
甜味超标 2020-12-01 03:53

So I have a table with this style:

table-layout: fixed;

Which makes all columns to be of the same width. I would like to have one column (t

4条回答
  •  一个人的身影
    2020-12-01 04:43

    You could just give the first cell (therefore column) a width and have the rest default to auto

    table {
      table-layout: fixed;
      border-collapse: collapse;
      width: 100%;
    }
    td {
      border: 1px solid #000;
      width: 150px;
    }
    td+td {
      width: auto;
    }
    150px equal equal


    or alternatively the "proper way" to get column widths might be to use the col element itself

    table {
      table-layout: fixed;
      border-collapse: collapse;
      width: 100%;
    }
    td {
      border: 1px solid #000;
    }
    .wide {
      width: 150px;
    }
    150px equal equal

提交回复
热议问题