akc42
akc42

Reputation: 5001

How can I color alternate rows of an iron list

I have an iron list which contains rows of a query from the database. I would like to color alternate rows so that they stand out.

My guess is that I want to put a class like "even" by computing something from the index. The put a class$="[[calculatedValue]]" in the row template. I can then color the row based on the existence of the even class.

However I am confused about how to do this. Any property I create within the hosting element is just that, ONE property. how do I extend that so that I have a calculation for every row.

Upvotes: 1

Views: 498

Answers (1)

Neil John Ramal
Neil John Ramal

Reputation: 3734

You don't even need to declare a class as you can do this with simple CSS.

Eg.

.row:nth-child(odd) {
  background-color: red; /* color 'em red */
}
.row:nth-child(even) {
  background-color: white;
}

Upvotes: 2

Related Questions