XF 2.3 Alternating Colors for Table Rows

Senkusha

Member
Licensed customer
I'm wanting to dress up my tables, make them more readable. Is there an easy way to add even/odd color background for rows in a table? I'm sure this is probably controlled through CSS, maybe in extra.less?
 
Solution
Sorry this:

CSS:
tr:nth-child(even) td {background-color: silver!important}

Or for both even and odd

tr:nth-child(even) td
{background-color: silver!important}

tr:nth-child(odd) td
{background-color: blue!important}
I asked Google AI and it said this: untested.

Code:
/* Target standard HTML tables or custom bbTables */
table, .bbTable table {
    tr:nth-child(odd) {
        background-color: @xf-contentAltBg; /* Odd row background */
    }
    
    tr:nth-child(even) {
        background-color: @xf-pageBackground; /* Even row background */
    }
}
 
Sorry this:

CSS:
tr:nth-child(even) td {background-color: silver!important}

Or for both even and odd

tr:nth-child(even) td
{background-color: silver!important}

tr:nth-child(odd) td
{background-color: blue!important}
 
Last edited:
Solution
Back
Top Bottom