HTML Table, first and last column fixed width and columns between dynamic, but equal width

前端 未结 7 1392
长发绾君心
长发绾君心 2021-01-04 09:35

Is it possible to have a table with width 100% (so the table fits the screen size), where the first and the last column have a fixed width, and the columns between take the

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 09:59

    Try this:

    As you can see the two centre column remain equal sized, due to the table-layout:fixed, even when the content is of different length. Try adding more and less content to the two centre columns.

    JSFiddle: http://jsfiddle.net/RtXSh/

    CSS

    table {
        width:100%;
        border-collapse:collapse;
        table-layout:fixed; 
    }
    
    td {
        border: 1px solid #333;
    }
    

    HTML

      
    test test test tes test test test test

提交回复
热议问题