Last Updated: February 25, 2016
·
559
· fredbird

Alternate styles (odd,even) with css3

For exemple, alternate colors through list items with :

li:nth-child(odd) {
    background: #ddd;
}
li:nth-child(even) {
    background: #eee;
}

I use it combined with a ol list to represent a CSV file content like this :

<ol class="csv-lines">
  <li>first line</li>
  <li>second line</li>
  <li>etc</li>
</ol>

I like things light and simple. Voilà !