1
这就是我想要实现:样式表的第一列不同,如果没有<thead>
这是我想要的风格标记:
<h2>Table with no header</h2>
<table>
<tbody>
<tr>
<td>First column - bold</td>
<td>Second column</td>
</tr>
<tr>
<td>First column - bold</td>
<td>Second column</td>
</tr>
</tbody>
</table>
<h2>Table with a header</h2>
<table>
<thead>
<tr>
<th>Header</th>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>First column - not bold</td>
<td>Second column</td>
</tr>
<tr>
<td>First column - not bold</td>
<td>Second column</td>
</tr>
</tbody>
</table>
关于如何达到预期结果的任何想法?
'!important'似乎没有必要(?):https://jsfiddle.net/91e9ukf9/ –
里克是正确的。 'thead + tbody td:first-child'比'td:first-child'更具体*,因此它将在不使用'!important'的情况下开创先例。 – Santi
Doh!我刚刚删除了'!important',它看起来都很完美。谢谢@RickHitchcock和@Santi。不知道我在那里做了什么......我想我已经有了我的答案。如果对任何人都有用,我会重写我的问题并添加一个答案。 – rouan