How to change alternate row color using CSS?

By | September 25, 2020

Hello if you want to change the color of the alternative row like the bootstrap data tables here is code for you

<table>

<tr class=”records”>

         <td>One</td>

         <td>one</td>

</tr>

<tr class=”records”>

      <td>Two</td>

       <td>two</td>

</tr>

</table>

 

Here is css for changing the alternative row you can change the background color of even or odd rows.

Css for changing the background color of the even rows 

tr:nth-child(even) { background-color: #000000; }

Css for changing the background color of the odd rows 

tr:nth-child(odd) { background-color: #000000; }

Leave a Reply

Your email address will not be published. Required fields are marked *