Set min-width in HTML table's

前端 未结 6 535
走了就别回头了
走了就别回头了 2020-12-29 01:40

My table has several columns.

Each column should have dynamic width that depends on the browser window size. On the other hand, each column must not be too tiny. So

相关标签:
6条回答
  • 2020-12-29 02:19

    One way should be to add a <div style="min-width:XXXpx"> within the td, and let the <td style="width:100%">

    0 讨论(0)
  • 2020-12-29 02:20

    Try using an invisible element (or psuedoelement) to force the table-cell to expand.

    td:before {
      content: '';
      display: block; 
      width: 5em;
    }
    

    JSFiddle: https://jsfiddle.net/cibulka/gf45uxr6/1/

    0 讨论(0)
  • 2020-12-29 02:23
    <table style="min-width:50px; max-width:150px;">
        <tr>
            <td style="min-width:50px">one</td>
            <td style="min-width:100px">two</td>
        </tr>
    </table>
    

    This works for me using an email script.

    0 讨论(0)
  • 2020-12-29 02:24

    try this one:

    <table style="border:1px solid">
    <tr>
        <td style="min-width:50px">one</td>
        <td style="min-width:100px">two</td>
    </tr>
    </table>

    0 讨论(0)
  • 2020-12-29 02:32

    min-width and max-width properties do not work the way you expect for table cells. From spec:

    In CSS 2.1, the effect of 'min-width' and 'max-width' on tables, inline tables, table cells, table columns, and column groups is undefined.

    This hasn't changed in CSS3.

    0 讨论(0)
  • <table style="border:2px solid #ddedde">
        <tr>
            <td style="border:2px solid #ddedde;width:50%">a</td>
            <td style="border:2px solid #ddedde;width:20%">b</td>
            <td style="border:2px solid #ddedde;width:30%">c</td>
        </tr>
        <tr>
            <td style="border:2px solid #ddedde;width:50%">a</td>
            <td style="border:2px solid #ddedde;width:20%">b</td>
            <td style="border:2px solid #ddedde;width:30%">c</td>
        </tr>
    </table>
    
    0 讨论(0)
提交回复
热议问题