Alterner la couleur des lignes d'une table

Résolu

Je voudrais qu'un TR sur 2 ait une couleur différente.

:root
{--SubTabBkgnd: #dbe7ef;}
tr.sub:nth-of-type(1) {background: blue;}
tr.sub:nth-of-type(2) {background: green;}
<tr class="sub">

Toutes les lignes ont la même couleur TabBkgnd = #dbe7ef

3 réponses

  1. tr.sub:nth-child(even) {
      background-color: #dddddd;
    }

    1
    1. Mille excuses, ça fonctionne avec nth-child, j'ai oublié de vider le cache de mon navigateur.

      1
      1. Merci mais ceci ne fonctionne pas non plus

        tr.sub:nth-child(odd) {background-color: #ECF3F7;}
        tr.sub:nth-child(even) {background-color: #E1EBF2;}
        0