How can I make it so that when --color
is set, it overrides the checkerboard background?
.cell {
display: inline-block;
width: 100px;
height: 100px;
/* from https://stackoverflow.com/a/51054396/65387 */
background-image: /* tint image */
linear-gradient(to right, rgba(204, 204, 204, 0.9), rgba(204, 204, 204, 0.9)), /* checkered effect */
linear-gradient(to right, black 50%, white 50%), linear-gradient(to bottom, black 50%, white 50%);
background-blend-mode: normal, difference, normal;
background-size: 25px 25px;
}
.a {
background-color: var(--color);
}
.b {
background: var(--color);
}
<div>
<div class="cell a">a1</div>
<div class="cell a" style="--color:red;">a2</div>
</div>
<div>
<div class="cell b">b1</div>
<div class="cell b" style="--color:red;">b2</div>
</div>
a2
doesn't override the background like I want.
b2
does, but then b1
becomes white.
Is there a way to do this without JavaScript?