table-layout 属性为表规定表格布局算法。
table { table-layout:fixed; }
值 | 描述 |
---|---|
automatic | 默认。列宽度由单元格内容设定。 |
fixed | 列宽由表格宽度和列宽度设定。 |
inherit | 规定应该从父元素继承 table-layout 属性的值。 |
HTML
<table class="ex1" border="1" width="100%"> <tr> <td width="5%">1000000000000000000000000000</td> <td width="95%">10000000</td> </tr> </table> <br> <table class="ex2" border="1" width="100%"> <tr> <td width="5%">1000000000000000000000000000</td> <td width="95%">10000000</td> </tr> </table>
CSS
table.ex1 {table-layout:auto} table.ex2 {table-layout:fixed}
执行结果
1000000000000000000000000000 | 10000000 |
1000000000000000000000000000 | 10000000 |