Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. CSS:层叠样式表
  3. CSS 参考
  4. 属性
  5. empty-cells

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

empty-cells

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

CSS 中empty-cells 属性定义了用户端user agent 应该怎么来渲染表格<table> 中没有可见内容的单元格的边框和背景。

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

只有当border-collapse 属性值是separate 时,才会生效。

初始值show
适用元素表格单元格元素
是否是继承属性
计算值as specified
动画类型离散值

语法

empty-cells 的属性值必须是以下取值中的一个。

取值

show

边框和背景正常渲染。与普通元素一样。

hide

边框和背景被隐藏。

语法形式

empty-cells =
show|
hide

示例

HTML

html
<table>  <tr>    <td>Moe</td>    <td>Larry</td>  </tr>  <tr>    <td>Curly</td>    <td></td>  </tr></table><br /><table>  <tr>    <td>Moe</td>    <td>Larry</td>  </tr>  <tr>    <td>Curly</td>    <td></td>  </tr></table>

CSS

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

结果

规范

Specification
Cascading Style Sheets Level 2
# empty-cells

浏览器兼容性

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp