Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

change css variable with javascript

let root = document.documentElement;

root.addEventListener("mousemove", e => {
  root.style.setProperty('--mouse-x', e.clientX + "px");
  root.style.setProperty('--mouse-y', e.clientY + "px");
});
Source by css-tricks.com #
 
PREVIOUS NEXT
Tagged: #change #css #variable #javascript
ADD COMMENT
Topic
Name
7+2 =