blob: 6098c59ac4914f1d72a2469e60443a862eead49a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
---
title: empty-cells
slug: Web/CSS/empty-cells
tags:
- CSS
- CSS属性
- CSS表格
translation_of: Web/CSS/empty-cells
---
<div>{{CSSRef}}</div>
<p>CSS中 <strong><code>empty-cells</code></strong> 属性定义了用户端 {{glossary("user agent")}} 应该怎么来渲染表格 {{htmlelement("table")}} 中没有可见内容的单元格的边框和背景。</p>
<pre class="brush:css no-line-numbers">/* Keyword values */
empty-cells: show;
empty-cells: hide;
/* Global values */
empty-cells: inherit;
empty-cells: initial;
empty-cells: unset;
</pre>
<p>只有当 {{cssxref("border-collapse")}} 属性值是 <code>separate</code> 时,才会生效。</p>
<p>{{cssinfo}}</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<p><code>empty-cells</code> 的属性值必须是以下取值中的一个。</p>
<h3 id="Values" name="Values">取值</h3>
<dl>
<dt><code>show</code></dt>
<dd>边框和背景正常渲染。与普通元素一样。</dd>
<dt><code>hide</code></dt>
<dd>边框和背景被隐藏。</dd>
</dl>
<h3 id="语法形式">语法形式</h3>
<pre class="syntaxbox">{{csssyntax}}
</pre>
<h2 id="Examples" name="Examples">示例</h2>
<h3 id="HTML">HTML</h3>
<pre class="brush: 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>
</pre>
<h3 id="Specifications" name="Specifications">CSS</h3>
<pre class="brush: css">.table_1 {
empty-cells: show;
}
.table_2 {
empty-cells: hide;
}
td,
th {
border: 1px solid gray;
padding: 0.5rem;
}</pre>
<h3 id="Result">Result</h3>
<p>{{ EmbedLiveSample('Examples', '100%', '200') }}</p>
<h2 id="Specifications" name="Specifications">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('CSS2.1', 'tables.html#empty-cells', 'empty-cells')}}</td>
<td>{{Spec2('CSS2.1')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
<div>
<p>{{Compat("css.properties.empty-cells")}}</p>
</div>
|