0

I am using custom color variables in order to change button colors and it is working fine. I am using elementRef.

Problem is when I try to change body background color, even when I point to the variable, body is still taking default color.

   :root{
 --body-background-color: #f7b219;
}

body,

html{
  background-color: var(--body-background-color) !important;
}

Where am I wrong?

1 Answer 1

1

Try

:root {
  --main-bg-color: #f7b219;
}

body {
  background-color: var(--main-bg-color);
}

Sign up to request clarification or add additional context in comments.

5 Comments

More relevant on using CSS variables here developer.mozilla.org/en-US/docs/Web/CSS/var
Yes, I have just like that in my code but it is still using default value.
OK. Can I see more of your code? Is the webpage live on internet that I could check it? Or also, apart from Angular are you using other libraries/frameworks that could be overriding this custom CSS? Because that code is 100% valid, that I am sure.
Yes, you were right!! I had a syntax problem in my code... Thanx!
Glad I could help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.