<分区>
<分区>
我有这样的问题,我有类似的事情:
<tr>
<td class="someclass">
<input />
</td>
...
<td> </td>
<td> </td>
..
</tr>
我想覆盖将仅应用于第一个 <td>
的“someclass”css 类与 <input>
.我该怎么做?也许有父规范或类似的东西?注意:我不能添加新类
最佳答案
可以使用css伪类first-child
Supported from IE7 +
.someclass{background:red;}
#table1 tr > td:first-child {background:blue;}
<table id="table1">
<tr>
<td class="someclass">One</td>
<td>Two</td>
<td>Three</td>
</tr>
</table>
请引用这个link了解更多关于 css 选择器的信息
关于html - 将样式应用于 tr 中包含的 td,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34395023/