2
要素を分離:ユニバーサルセレクタは、私はそのようなテーブルの両方の目とTD要素のスタイルをしたい
<table>
<tr>
<th>Abc</th>
<td>Cde</td>
</tr>
<tr>
<th>Abc</th>
<td>Cde</td>
</tr>
</table>
私はそれにクラスを追加したくないので、私はそのようにそれを実行する必要があります。
tr td, tr th{background:#dddddd;}
tr:nth-child(even) td, tr:nth-child(even) th{background:#ffffff;}
しかし、以下のような不利な点はありますか?
tr > *{background:#dddddd;}
tr:nth-child(even) > *{background:#ffffff;}
直下の子だけが 'td'と' th'であるため、これを行う際に問題はありません。パフォーマンスに関する懸念がある場合は、この回答を読んでください。[ここ](http://stackoverflow.com/a/13432169) –