99Coder
99Coder

Reputation: 75

Angular 9 - Cannot change body background with css variable

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?

Upvotes: 0

Views: 940

Answers (1)

avia
avia

Reputation: 1578

Try

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

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

Upvotes: 1

Related Questions