I have this example below where .bar
is inheriting color: var(--color);
from it's parent.
If I then redefine --color
to another color in .bar
, the custom property doesn't update.
Can someone explain why, and what's needed to be able to change the value of --color
in children that inherit that custom property?
:root {
--color: red;
--color2: blue;
}
.foo {
color: var(--color);
}
.bar {
--color: var(--color2);
}
<div class="foo">
foo
<div class="bar">
bar
</div>
</div>