首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

表格布局 | table-layout

table-layoutCSS属性指定用于铺陈算法<table>单元格,行和列。

代码语言:javascript
复制
/* Keyword values */
table-layout: auto;
table-layout: fixed;

/* Global values */
table-layout: inherit;
table-layout: initial;
table-layout: unset;

Initial value

auto

应用对象

table and inline-table elements

是否可继承

no

媒体

visual

计算值

as specified

动画类型

discrete

规范顺序

the unique non-ambiguous order defined by the formal grammar

语法

auto默认情况下,大多数浏览器使用自动表格布局算法。表格及其单元格的宽度将根据内容进行调整。

fixed表格和列的宽度由单元格的宽度

tablecol元素来设置宽度或第一行单元格的宽度。

后续行中的单元格不会影响列宽度。在“固定”布局方法下,一旦第一个表格行被下载和分析,就可以呈现整个表格。这可以加快渲染时间,而不是“自动”布局方法,但后续单元格内容可能不符合提供的列宽。单元格使用该overflow属性来确定是否剪辑任何溢出的内容,但仅当表格具有已知宽度时; 否则,他们不会溢出细胞。

形式语法

代码语言:javascript
复制
auto | fixed

HTML

代码语言:javascript
复制
<table>
  <tr><td>Ed</td><td>Wood</td></tr>
  <tr><td>Albert</td><td>Schweitzer</td></tr>
  <tr><td>Jane</td><td>Fonda</td></tr>
  <tr><td>William</td><td>Shakespeare</td></tr>
</table>

CSS

代码语言:javascript
复制
table {
  table-layout: fixed;
  width: 100px;
  border: 1px solid red;
}

td {
  border: 1px solid blue;
}

结果

规范

Specification

Status

Comment

CSS Level 2 (Revision 1)The definition of 'table-layout' in that specification.

Recommendation

Initial definition.

浏览器兼容性

Feature

Chrome

Edge

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

? - 14.0 +

(Yes)

1.0 (1.7 or earlier)

5.0

7.0

1.0

Feature

Android

Chrome for Android

Edge

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

? 1.5

?

(Yes)

?

?

? 9.8.0

? 3.0

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com