Answers for "variables css javascript"

14

how to change a css variable with javascript

var root = document.querySelector(':root');
root.style.setProperty('--variable', 'lightblue');
/or/
root.style.setProperty('--variable', myColor);
Posted by: Guest on February-17-2021
2

js set css variable

document.documentElement.style.setProperty("--main-background-color", "green");
Posted by: Guest on January-07-2021
1

variables css

:root {
    --main-bg-color: brown;
  }
  
.uno {
    color: white;
    background-color: var(--main-bg-color);
    margin: 10px;
    width: 50px;
    height: 50px;
    display: inline-block;
}
Posted by: Guest on September-07-2020

Code answers related to "variables css javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language