I am trying to setup a table that will have X number of rows, with each row's background color set by ID (or class, either way... this is to identify each row's category). On top of that, I would like to use nth-child to change the opacity for the background of each even row, so that if there are a lot of rows for a particular category, the user can easily skim the table. I setup some code on JSFiddle, but the entire row's content (text, background, border) is affected, not just the background (which makes sense, of course).
#a { background:lightblue; }
#b { background:orange; }
#c { background:lightgreen; }
.row:nth-child(even) {
opacity: .60;
}
So far, all of the solutions I have found either don't address the different row background colors, or involve a convoluted use of multiple layers that create issues with the nth-child selector. It also appears most of the answers for this are from awhile ago, so I am hoping that there is a more recent solution.
Any help or advice is greatly appreciated!