How to control Sass Variable with javascript

前端 未结 8 1628
予麋鹿
予麋鹿 2020-12-01 17:47

I have a Sass file which is generating a CSS file. I have used many variables in my sass file for background color, font-size, now I want to control my all variables through

8条回答
  •  半阙折子戏
    2020-12-01 18:35

    variable in style

    :root {
    
      --bg: #000;
      --font-size:12px;
    
    }
    

    change variable value by javascript

    root.style.setProperty('--bg', '#fff');
    root.style.setProperty('--font-size', '14px');
    

提交回复
热议问题