tableLayout 属性用来显示表格单元格、行、列的算法规则。
固定表格布局与自动表格布局相比,允许浏览器更快地对表格进行布局。
在固定表格布局中,水平布局仅取决于表格宽度、列宽度、表格边框宽度、单元格间距,而与单元格的内容无关。
通过使用固定表格布局,用户代理在接收到第一行后就可以显示表格。
在自动表格布局中,列的宽度是由列单元格中没有折行的最宽的内容设定的。
此算法有时会较慢,这是由于它需要在确定最终的布局之前访问表格中所有的内容。
</>code
- Object.style.tableLayout=automatic|fixed
值 | 描述 |
---|---|
automatic | 默认。列宽度由单元格内容设定。 |
fixed | 列宽由表格宽度和列宽度设定。 |
本例设置固定表格布局:
</>code
- <html>
- <head>
- <script type="text/javascript">
- function setFixedTableLayout()
- {
document.getElementById('myTable').style.tableLayout="fixed";
- }
- </script>
- </head>
- <body>
- <table id="myTable" border="1" width="100%">
- <col width="20%"><col width="40%"><col width="40%">
- <tr>
- <td>1000000000000000000000000000</td>
- <td>10000000</td>
- <td>100</td>
- </tr>
- </table>
- <input type="button" onclick="setFixedTableLayout()"
- value="Set fixed table layout">
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号