【发布时间】:2018-05-19 08:15:12
【问题描述】:
来自 W3C 的Dynamic rows and column effects
此折叠值会导致整个行或列从显示中移除,并且通常由行或列占用的空间可用于其他内容。
从上面我的理解是,如果我做类似下面的 sn-p 的事情,结果应该是这样的:
但它却显示为:
table tr td {
visibility: collapse;
}
.red {
background-color: red;
}
/* All the below don't work as well. */
table tr td:first-child {
visibility: collapse;
}
table colgroup col {
visibility: collapse;
}
table colgroup {
visibility: collapse;
}
/* Works but I am trying to understand the why the column doesn't work as
intended */
/* table tr {
visibility: collapse;
} */
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table>
<colgroup>
<col class="red">
<col>
</colgroup>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 11</td>
<td>Data 12</td>
</tr>
</tbody>
</table>
<p>Should show below the header row</p>
</body>
</html>
注意
我也尝试将折叠应用于table tr td:first-child、table colgroup 和table colgroup col,但无济于事。但是,如果我在 table tr 上应用折叠,则该段落将按预期显示在页面顶部。
此外,我知道我可以使用display: none; 达到预期的结果,但我试图找出我是否误解了文档中的某些内容。另外,我在 Chrome、Firefox 和 Edge 上试过代码,结果都是一样的。
【问题讨论】:
标签: css css-tables w3c