CSS

空单元 | empty-cells

该empty-cellsCSS属性指定用户端应该如何渲染周围的边框和背景<table>有没有可见的内容的单元格。此属性时才适用border-collapse的separate。

/* Keyword values */ empty-cells: show; empty-cells: hide; /* Global values */ empty-cells: inherit; empty-cells: initial; empty-cells: unset;

Initial valueshow
应用对象table-cell elements
是否可继承yes
媒体visual
计算值as specified
动画类型discrete
规范顺序the unique non-ambiguous order defined by the formal grammar

语法

empty-cells属性被指定为下面列出的关键字值之一。

show边界和背景像正常区块一样绘制。

形式语法

show | hide

HTML

<table class="table_1"> <tr> <td>Moe</td> <td>Larry</td> </tr> <tr> <td>Curly</td> <td></td> </tr> </table> <table class="table_2"> <tr> <td>Moe</td> <td>Larry</td> </tr> <tr> <td>Curly</td> <td></td> </tr> </table>

CSS

.table_1 { empty-cells: show; } .table_2 { empty-cells: hide; } td, th { border: 1px solid gray; padding: 0.5rem; }

结果

规范

SpecificationStatusComment
CSS Level 2 (Revision 1)The definition of 'empty-cells' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support1.0(Yes)1.0 (1.7 or earlier)8.04.01.2

FeatureAndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support1(Yes)1.0 (1.0)863.1