设置不同的表格布局算法:
table.a {
table-layout: auto;
width: 180px;
}
table.b {
table-layout: fixed;
width: 180px;
}
亲自试一试 »
这个table-layout
属性定义用于布局表格单元格、行和列的算法。
提示:表布局的主要好处:固定;是表格渲染速度更快。在大型表格上,在浏览器呈现整个表格之前,用户将看不到表格的任何部分。因此,如果您使用 table-layout:fixed,用户将在浏览器加载并呈现表格的其余部分时看到表格的顶部。这给人的印象是页面加载速度快得多!
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
table-layout | 14.0 | 5.0 | 1.0 | 1.0 | 7.0 |
table-layout: auto|fixed|initial|inherit;
Value | Description | Demo |
---|---|---|
auto | Browsers use an automatic table layout algorithm. The column width is set by the widest unbreakable content in the cells. The content will dictate the layout | Demo ❯ |
fixed | Sets a fixed table layout algorithm. The table and column widths are set by the widths of table and col or by the width of the first row of cells. Cells in other rows do not affect column widths. If no widths are present on the first row, the column widths are divided equally across the table, regardless of content inside the cells | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS教程:CSS表
HTML DOM 参考:表布局属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!