Aru*_*hit 3 html css html-table css-selectors
<div id="myelement">
<table class="myclass">
<tbody>
<tr>
<td>something</td>
<td>
<table>
<tbody>
<tr> hari </tr>
</tbody>
</table>
</td>
</tr>
<tr>
foo
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
"//tbody[1]"
我正在寻找一个CSS表达式,它应首先选择tbody哪个是直接的孩子table,而不是里面的孩子tr.
如果我使用CSS tbody,那么它将选择2,但我正在寻找一种方法来解决它.我知道table>tbody会工作,我正在寻找是否有更多.在我的情况下,我不能使用table>tbody.
tbody tr td:first-of-type {
color: red;
}
Run Code Online (Sandbox Code Playgroud)
td:first-of-type 也会有效.
:nth-of-type(1)并且:first-of-type是一样的.文件