我正在尝试将样式应用于表数据,但无法获得正确的元素,因为它们没有类或I。这些表具有相同的类名,我可以通过使用table:nth-of-type(2)来隔离正确的表。我只是想不出如何正确地将选择器串在一起以获得正确的元素。
我最近尝试过的东西是
div#esri_dijit_Legend__BuckQuery表:nth-of-type(2)> tbody > tr >td:第一个孩子
下面是html的示意图。
<table class="className">
<tbody>
<tr>
<td> Need to apply style to this element only
<td>
</tr>
</tbody>
</table>
<table class="className">
<tbody>
<tr>
<td> Don't want this element
<td>
</tr>
</tbody>
</table>
No errors, just nothing happens.The problem I am having is stringing together to two selectors correctly. I know there is a correct syntax for doing this.
Thanks
发布于 2019-09-20 20:49:29
<style>
.className:first-of-type tr:first-child td:first-child
{
background:red;
}
</style>
<table class="className">
<tbody>
<tr>
<td> Need to apply style to this element only
<td>
<td>
There is no style on this element
<td>
</tr>
</tbody>
</table>
<table class="className">
<tbody>
<tr>
<td> Don't want this element
<td>
</tr>
</tbody>
</table>
https://stackoverflow.com/questions/58034043
复制