2017-05-19 17 views
-2

私はasp.net mvcアプリケーション&のhttps://datatables.net/テーブルを使用していますが、最初の列の偶数行の背景色を変更したいとします。偶数行のhtmlテーブルの背景色を変更する

スタイリングはテーブル本体にのみ適用し、テーブルヘッドには適用しないでください。

私は以下のCSSを持っていますが、行全体の偶数行の背景色を変更しても、偶数行の拳列にはどのように適用できますか?

.table-striped > tbody > tr:nth-of-type(even) { 
    background-color: #e0f0ff;  
} 
+2

.tableストライプ>のtbody> TR:n番目の-の型(さえ)TD:第一子{} –

+0

なぜTR上のクラスを入れていないし、前のビットを取り除きますか? – ThisGuyHasTwoThumbs

+0

@Nick理由のためにありがとう – StackTrace

答えて

1

ためtdを使用することができ、あなたが答えです:

.table-striped > tbody > tr:nth-of-type(even) td:first-child{background-color: #e0f0ff; } 
0

代わりのtrあなたはここで背景

.table-striped > tbody > tr:nth-of-type(even) td:first-child { 
    background-color: #e0f0ff;  
} 
+1

あなたは何か不可欠なものを欠いています:(質問から) "偶数行の_背景色**最初の列** ._" – KarelG

0

あなたが使用することができます ":第一子を"。

.table-striped > tbody > tr:nth-of-type(even) { 
    background-color: #e0f0ff;  
} 
.table-striped > tbody > tr:nth-of-type(even) td:first-child { 
    background-color: red; 
} 
関連する問題