empty-cells - CSS: Cascading Style Sheets 编辑
The empty-cells
CSS property sets whether borders and backgrounds appear around <table>
cells that have no visible content.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
This property has an effect only when the border-collapse
property is separate
.
Syntax
/* Keyword values */
empty-cells: show;
empty-cells: hide;
/* Global values */
empty-cells: inherit;
empty-cells: initial;
empty-cells: unset;
The empty-cells
property is specified as one of the keyword values listed below.
Values
show
- Borders and backgrounds are drawn like in normal cells.
hide
- No borders or backgrounds are drawn.
Formal definition
Initial value | show |
---|---|
Applies to | table-cell elements |
Inherited | yes |
Computed value | as specified |
Animation type | discrete |
Formal syntax
show | hide
Example
Showing and hiding empty table cells
HTML
<table class="table_1">
<tr>
<td>Moe</td>
<td>Larry</td>
</tr>
<tr>
<td>Curly</td>
<td></td>
</tr>
</table>
<br>
<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;
}
Result
Specifications
Specification | Status | Comment |
---|---|---|
CSS Level 2 (Revision 1) The definition of 'empty-cells' in that specification. | Recommendation | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论