CSS to change nth row of Table background

I am trying to write CSS to change the background color of alternate rows in a table.

This CSS is ignored.

Other ideas?

.table-row:nth-child(even) {
background: gray !important;

Try this:

.rt-tr-group:nth-child(even) {
  background: #ccc;

You need to choose the parent element for the background to take effect.

1 Like

Perfect - thank you!

1 Like

If I set a table to use the new Infinite Scrolling feature Scrollable tables - #13 by mseflek then the CSS does not work for the table.

Is there a way to have the nth row background as part of a scrolling table?

Victroria from Retool solved this - it works for nth-child background color settings in a scrolling table

Thanks @victoria

#rt-table-documentsTable > div:nth-child(2) > div > div > div:nth-child(odd) {
  background-color: blue;