HTML table: column width percentage

前端 未结 2 2107
时光取名叫无心
时光取名叫无心 2021-02-02 08:36

I have a table with 7 columns. I want the columns to be of the following widths:

  • 3 columns x width=20%
  • 4 columns x width=10%
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-02 09:20

    Your CSS works as expected, in a way that the widths of the table heads and cells are correct. However:

    th by default have text-align: center applied, while the td element has not.

    So you should add either to the td or th the same text alignment. E.g.:

    th {
        text-align: left;
    }
    

提交回复
热议问题