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

前端 未结 9 1343
花落未央
花落未央 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:36

    If you're not too picky about which column widths the browser comes up with, as long as they're the same across different tables, you can use the CSS table-layout property (supported by all major browsers) in combination with a table width:

    table {
        table-layout: fixed;
        width: 100%;
    }
    

    This causes all columns (without a specified width) to have the same width, regardless of the table content.

提交回复
热议问题