Skip to content

Striped table rows cleancss fix#663

Open
Yohn wants to merge 2 commits into
picocss:mainfrom
Yohn:Yohn-striped-tables
Open

Striped table rows cleancss fix#663
Yohn wants to merge 2 commits into
picocss:mainfrom
Yohn:Yohn-striped-tables

Conversation

@Yohn

@Yohn Yohn commented Mar 15, 2025

Copy link
Copy Markdown

Its a little dirty, but it works. CleanCSS was causing the issue, and we can tell it to not modify that code block. I tried it a few different ways before I settings with this.

Its a little dirty, but it works. CleanCSS was causing the issue, and we can tell it to not modify that code block.
I tried it a few different ways before I settings with this.
@lucaslarroche

lucaslarroche commented Mar 16, 2025

Copy link
Copy Markdown
Member

@Yohn, great find, you are right, it's the minifier.

I did more tests and actually we could do this:

tbody {
  // Striped rows skip hidden elements (`odd of :not([hidden])`), `:is()` prevents minifier issues.
  tr:is(:nth-child(odd of :not([hidden]))) {
    th,
    td {
      background-color: var(#{$css-var-prefix}table-row-stripped-background-color);
    }
  }
}

What do you think?

@Yohn

Yohn commented Mar 16, 2025

Copy link
Copy Markdown
Author

Nice find! Idk why I didn't think to try is() when I was messing with that. I'll modify this pull request for that change.

use `:is()`
Amaury added a commit to Digicreon/muCSS that referenced this pull request Mar 22, 2026
…#663). Progressive enhancement with fallback for older browsers.
@Amaury

Amaury commented Mar 23, 2026

Copy link
Copy Markdown

We applied this fix in µCSS, using tr:nth-child(odd of :not([hidden])) with a basic tr:nth-child(odd) fallback for older browsers.

We didn't need the :is() wrapper since µCSS doesn't use CleanCSS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants