2016-11-17 9 views
1

backbround-colortrtableに追加するには、css not inlineスタイルを使用してください。HTML表にCSSを追加しますか?

いずれかを教えてください。

私のhtmlコードの下

<table> 
    <tr> 
    <td>First TR</td> 
    </tr> 
    <tr> 
    <td>Second TR</td> 
    </tr> 
    <tr> 
    <td>Third TR</td> 
    </tr> 
    <tr> 
    <td>Four TR</td> 
    </tr> 
    <tr> 
    <td>Fifth TR</td> 
    </tr> 
</table> 

おかげ

+1

試してみたことがありますか? – kukkuz

答えて

1

table>tbody>tr:nth-child(3) { 
 
background-color:red; 
 
}
<table> 
 
    <tr> 
 
    <td>First TR</td> 
 
    </tr> 
 
    <tr> 
 
    <td>Second TR</td> 
 
    </tr> 
 
    <tr> 
 
    <td>Third TR</td> 
 
    </tr> 
 
    <tr> 
 
    <td>Four TR</td> 
 
    </tr> 
 
    <tr> 
 
    <td>Fifth TR</td> 
 
    </tr> 
 
</table>
でアクセスされています

0

あなたがでそれを行うことができますこのセレクタ:

table tr:nth-child(3){ 
    background-color: #rgb; /*your color */ 
} 

:nth-child(n)番号を受け取り、それが基づくものであり、即ち、第1子 は1

関連する問題