gpt4 book ai didi

html - 在样式标签中显示无表格单元格

转载 作者:行者123 更新时间:2023-11-28 04:47:06 24 4
gpt4 key购买 nike

我可能遗漏了一些非常明显的东西,但是请考虑以下代码(在 Edge 和 Chrome 中测试):

<head>
<style>
.table td { display:table-cell; }
.hide { display: none; }
</style>
</head>
<body>
<table class="table">
<tr>
<td class="hide">This is supposed to be hidden</td>
</tr>
</table>
</body>

这是一个JSFiddle demo

为什么是<td> child 无视 display:none

现在,我知道,例如,删除 .table类或内联 <td style="display:none">会让我得到想要的结果(隐藏单元格)。

我有兴趣了解这种行为的逻辑。

最佳答案

Why is the child ignoring the display:none?

因为 .table td.hide 更具体。你遇到了一个叫做 css specifitiy 的概念.

看这里:https://specificity.keegan.st

关于html - 在样式标签中显示无表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42050629/

24 4 0