2016-12-01 15 views
-4

我需要做的這個表中的CSS:使用css和html的Zebra表?

I need to do this table in css

我需要幫助,請,我不知道該怎麼做。

+1

瞭解HTML和CSS,你可以沒有所示努力去做 – Alexis

+0

ー1。 –

+1

此網站旨在幫助開發人員,而不是替換它們 –

回答

0

您可以使用:nth-of-type(odd)來做到這一點。

tr:nth-of-type(odd) {background-color: green;} 
0

將數據替換爲高興,理想情況下,您的一些代碼會更好。給類highlight突出顯示tr s。注意這個例子包括bootstrap 3分鐘的CSS。

.highlight { 
 
    background-color: lightgreen; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 

 
<div class="container"> 
 
    <table class="table table-bordered"> 
 
    <thead> 
 
     <tr> 
 
     <th>Firstname</th> 
 
     <th>Lastname</th> 
 
     <th>Email</th> 
 
     </tr> 
 
    </thead> 
 
    <tbody> 
 
     <tr class="highlight"> 
 
     <td>John</td> 
 
     <td>Doe</td> 
 
     <td>[email protected]</td> 
 
     </tr> 
 
     <tr> 
 
     <td>Mary</td> 
 
     <td>Moe</td> 
 
     <td>[email protected]</td> 
 
     </tr> 
 
     <tr class="highlight"> 
 
     <td>July</td> 
 
     <td>Dooley</td> 
 
     <td>[email protected]</td> 
 
     </tr> 
 
    </tbody> 
 
    </table> 
 
</div>