我已经看过this ,这不是我在这里需要的..
我需要类似的东西
table.mytable tr first-td's { border: 1px solid black; }
对于
<table class="mytable">
<tr>
<td>This has the border</td>
<td>no border</td>
<td>no border</td>
</tr>
<tr>
<td>This has the border</td>
<td>no border</td>
<td>no border</td>
</tr>
<tr>
<td>This has the border</td>
<td>no border</td>
<td>no border</td>
</tr>
</table>
如果这不可能,请告诉我,我会很难过。
如果需要完成工作,Javascript/jQuery 是可以接受的。
最佳答案
table.mytable tr td:first-child { border: 1px solid black; }
https://developer.mozilla.org/en-US/docs/CSS/:first-child
也适用于 jQuery ( http://api.jquery.com/first-child-selector/ ):
$('table.mytable tr td:first-child')
关于javascript - 仅将 CSS 规则应用于 <tr> 中的第一个 <td> 而不分配类/id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11959436/