Background color alternative row in template dynamically after <tbody id="lineItem"> CRM

Background color alternative row in template dynamically after <tbody id="lineItem"> CRM

Code snippet :
 
<table>
<tbody id="lineItem">
 
<tr>
<td>${Invoice.Qty}</td>
<td>${Invoice.Product Name}</td>
</tr>
 
</tbody>
</table>
 
After export as PDF then select my custom template , When I open my PDF . I see there is no alternative color ,
even I tried through css :
snippet : 
 
<style>
 
.test:nth-child(even)
{
background-color:red
}
 
.test:nth-child(odd)
{
background-color:blue
}
 
</style>
 
<table>
<tbody id="lineItem">
 
<tr class="test">
<td>${Invoice.Qty}</td>
<td>${Invoice.Product Name}</td>
</tr>
 
</tbody>
</table>
 
Please tell me ,
I need this Output .
 
background color : blue  <tr><td> 2</td><td> Product Name2</td></tr>
background color : red  <tr><td> 3</td><td> Product Name3</td></tr>
background color : blue  <tr><td> 4</td><td> Product Name4</td></tr>
background color : red  <tr><td> 5</td><td> Product Name5</td></tr>