[CSS]nth-childで偶数の行のスタイルシートを適用する

2021年8月25日

書式
tr:nth-child(2n)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<style>
tr:nth-child(2n) {
background-color: skyblue;
font-size: 20px;
}
</style>
<table>
<tr><td>111</td></tr>
<tr><td>222</td></tr>
<tr><td>333</td></tr>
<tr><td>444</td></tr>
</table>
<style> tr:nth-child(2n) { background-color: skyblue; font-size: 20px; } </style> <table> <tr><td>111</td></tr> <tr><td>222</td></tr> <tr><td>333</td></tr> <tr><td>444</td></tr> </table>
<style>
  tr:nth-child(2n) {
    background-color: skyblue;
    font-size: 20px;
  }

</style>
<table>
  <tr><td>111</td></tr>
  <tr><td>222</td></tr>
  <tr><td>333</td></tr>
  <tr><td>444</td></tr>
</table>

 

CSS

Posted by arkgame