Answers for "how to put a color variable from js to css"

4

how to change css variable in javascript

document.documentElement.setAttribute("style", "--main-background-color: green");
Posted by: Guest on September-11-2020
2

css variables

:root {
  --background-color: #333;
  --text-color: #fff;
}
body {
  background-color: var(--background-color);
  color: var(--text-color);
}
Posted by: Guest on December-13-2020

Code answers related to "how to put a color variable from js to css"

Code answers related to "Javascript"

Browse Popular Code Answers by Language