rfornal
rfornal
Reputation Top 5%
rfornal
1 Snippet  (651st place)
Published
1 Channel
Created
2 Channels
Following
37 points  (772nd place)
Reputation
Junior Code Generator
Junior Publisher
Junior Trend Maker
Junior Judge
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Junior Famous Coder

Recent Snippets See all snippets by rfornal

public by rfornal  2437  1  6  1

Simple: Alternate Row Colors (cn be used for ordered list [li], unordered list[li], or tables [using tr]). More correct than nth-of-type which can get dicey when selecting DOM elements. The LI and TR can be switched to almost any HTML tag.

li:nth-child(even) {
  background-color: red;
}
li:nth-child(odd) {
  background-color: white;
}

tr:nth-child(even) {
  background-color: red;
}
tr:nth-child(odd) {
  background-color: white;
}
;