【发布时间】:2021-12-15 03:46:30
【问题描述】:
编写一个简单的html 表时,我在浏览器之间遇到了一个令人惊讶的渲染错误。
因为它太基础了,也许我做错了什么......
当您加载这个MDN page 时,您可以看到一个非常简单的表格(带有html 和css)。
我的目标是隐藏第一列。
乍一看好像很简单,加style="visibility:collapse"。
下面所有html代码:
<table>
<caption>Superheros and sidekicks</caption>
<colgroup>
<col style="visibility:collapse">
<col span="2" class="batman">
<col span="2" class="flash">
</colgroup>
<tr>
<td> </td>
<th scope="col">Batman</th>
<th scope="col">Robin</th>
<th scope="col">The Flash</th>
<th scope="col">Kid Flash</th>
</tr>
<tr>
<th scope="row">Skill</th>
<td>Smarts</td>
<td>Dex, acrobat</td>
<td>Super speed</td>
<td>Super speed</td>
</tr>
</table>
它在Chrome 中完美运行,但在Safari 中却不行。其他浏览器不知道。
这是为什么?有破解吗?
谢谢。
【问题讨论】:
-
至于为什么会这样,只是因为苹果从来不关心实现它。见bugs.webkit.org/show_bug.cgi?id=8735。如下所述,将
display:none应用于 td:nth-child(3) 或其他任何可行的解决方法。 -
谢谢,我就是这么做的。但是,如果没有这个错误,我的代码会更干净......
标签: css google-chrome browser html-table safari