【发布时间】:2014-09-23 22:51:06
【问题描述】:
我正在使用数据表并使用下面的 css 来隐藏表格的标题。
table.dataTable thead {
display: none;
}
现在发生的事情是我有两个表,ID 为 userList1 和 userList2。
我想要做的只是将此 css 应用于 id 为 userList1 的表。
知道如何完成这项工作吗?
我试过了
#userList1.table.dataTable thead {
display: none;
}
#userList1 > table.dataTable thead {
display: none;
}
但没有一个工作。
我不确定上面是对还是错,但我试过了。我是 CSS 新手。
HTML代码是
表 1
<table id="userList" class="responsive dataTable" dir="LTR" style="width: 100%;border: 0px;" aria-describedby="userList_info">
表 2
<table id="userList:2:userList2" class="responsive appointments" dir="LTR"></table>
<table id="userList:1:userList2" class="responsive appointments" dir="LTR"></table>
<table id="userList:0:userList2" class="responsive appointments" dir="LTR"></table>
注意:我有两张桌子..
表 1 有内表作为表 2...
所以我的桌子是
<table id="userList" class="responsive dataTable" dir="LTR" style="width: 100%;border: 0px;" aria-describedby="userList_info">
<table id="userList:2:userList2" class="responsive appointments" dir="LTR"></table>
<table id="userList:1:userList2" class="responsive appointments" dir="LTR"></table>
<table id="userList:0:userList2" class="responsive appointments" dir="LTR"></table>
</table>
注意我使用的是 JSF 语言,内表 ID 是由 JSF 创建的...
JSFiddle Link
【问题讨论】:
-
这里
#userList1.dataTable thead或只是#userList1 thead你的原始代码不起作用,因为table不是一个类,所以#userList1.table没有任何目标。如果这些不起作用,那么您将需要提供表格标记。只是表格标签就可以了,不需要它的胆量 -
请提供您的 HTML 示例
-
为什么不只是
#userList1 thead {display: none;}? -
#userList>thead{...}? -
下次如果您使用实际使用的 HTML 更新而不是多次更新它会非常好。