-
Notifications
You must be signed in to change notification settings - Fork 756
Closed
Labels
Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.Used when the issue is more of a question than a problem, and it's been answered.css-variables-1Current WorkCurrent Work
Description
I’m a bit confused by “var() functions are substituted at computed-value time” and how it relates to inheritance.
div {
--color-accent: lime;
--color-text: var(--color-base);
--color-bg: var(--color-accent);
}
figure.theme-american {
--color-base: red;
--color-accent: blue;
}
figure.theme-irish {
--color-base: green;
--color-accent: orange;
}
p {
/* isn’t --color-text: var(--color-base); inherited here? */
/* isn’t --color-bg: var(--color-accent); inherited here? */
color: var(--color-text);
background-color: var(--color-bg);
}<div>
<figure class="theme-american">
<p>My text should be red, and my background should be blue.</p>
<!-- They’re not. The text is black (inherited) and the background is lime. -->
</figure>
</div>I thought all custom properties inherit, so wouldn’t the paragraph inherit the --color-text and --color-bg properties from the div? Since it also inherits the --color-base and --color-accent from the figure, shouldn’t the color be red and the background-color be blue?
Sources:
Metadata
Metadata
Assignees
Labels
Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.Used when the issue is more of a question than a problem, and it's been answered.css-variables-1Current WorkCurrent Work