Is it possible to have alternating row colors?

,

I’ve made a basic program to teach myself how to use ColumnView. This is what it looks like normally. I’ve then decided to mess with its visuals, so now it loads a CSS file with the following contents:

columnview listview row{
background-color: maroon;
}

columnview listview row:hover{
background-color: green;
}

columnview listview row:selected{
background-color: navy;
}

which causes the program to look like this instead. It’s fun!

I wish to push this a bit further, and have rows with alternating colors, so odd and even rows would be different shades of red. Unfortunately, after scouring the documentation, I was unable to find anything that would allow me to do this. I experimented enough to figure out that my best bet would be to somehow retrieve the rows from the ColumnViews and then give them names so they load different attributes from the CSS file. But I’m not sure if doing this is possible, or if it’s even the appropiate way to go about this.

ColumnView, like other list views, recycles the row/column/cell widgets, so it cannot implement CSS pseudo-classes like :nth-child, :first-child and :last-child. This means you can’t do :nth-child(odd) or :nth-child(2n+1).

That is unfortunate. Thank you for the prompt response regardless.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.