79818021

Date: 2025-11-12 16:55:37
Score: 0.5
Natty:
Report link

WAIT Nevermind I'm an idiot. This is silly easy. In case anyone else is looking for this: just use css variables.

.redSquare {
    --main-bg-color: red;
    background-color: var(--main-bg-color);
}

.greenSquare {
    --main-bg-color: green;
    background-color: var(--main-bg-color);
}
.changeBG {
    background-color: var(--main-bg-color);
    transition: background-color 0.5s;
}
.changeBG:hover {
    background-color: blue;
    transition: background-color 0.5s;
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: chrisjfinlay