Seeking best approach to styling dynamic CSS content

I'm designing a website in Webflow. The site has card elements that each have assigned colors that correspond to their "rating". The current colors, however, aren't color-blind friendly.

I'd like to add patterns to each card to fix this: zig-zags, Xs, Os, things like that, such that the texture can provide some context.

I'd like to code this in CSS using gradient patterns, but I'm not clear on the best approach to accomplish this other than creating the illustrations and loading those in. My hunch is to do something like

.library__cardimage:has(background-color: #d7f6d2) {/*gradient pattern 1 */ }
.library__cardimage:has(background-color: #eef2ff) {/*gradient pattern 2 */ }
.library__cardimage:has(background-color: #ffebce) { /*gradient pattern 3 */ }


But I suspect that this is incorrect for a number of reasons.
Was this page helpful?