Any way to synchronize table column widths with HTML + CSS?

前端 未结 9 1327
花落未央
花落未央 2020-12-24 05:05

I have a number of tables with the same columns and it would look a lot nicer if they shared the same column widths. Is such a thing possible? Putting them in the same tab

9条回答
  •  无人及你
    2020-12-24 05:54

    You can sync the column widths by combining the tables (as suggested by @Stefanvds), but using a tbody + th for each:

    table {
      border-collapse: collapse;
    }
    
    table thead,
    table tbody {
      border-bottom: solid;
    }
    
    table tbody th {
      text-align: left;
    }
    ID Measurement Average Maximum
    Cats
    93 Legs 3.5 4
    10 Tails 1 1
    English speakers
    32 Legs 2.67 4
    35 Tails 0.33 1

    Source: Example in the HTML spec itself

提交回复
热议问题