I want to generate css
dynamically at run time.
Initially I had used sass
and defined some variables and was using those variables. But css has to be generated first from the scss
. Sass had given me flexibility to use variables and functions but still I was not able to changes them at run time via javascript
.
One way was to change the inline styles via javascript
but that approach was not completly flexible.
document.getElementById("myDiv").style.color = "red";
I don't want to do above, neither I want to attach any <style>
attribute via javascript.
I want to use javascript but not for chaniging each and every style properties. I want to achieve scss like effect using css and javascript but at run time i.e dynamically.
E.g. suppose I got the color
information from the ajax call now I want to change the whole theme of website based on that color
received immediately without restarting or re-deploying my application.
e.g
as done in scss
.myClass {
background:$color;
// Update color value dynamically at run-time
}
Is it even possible or I am thinking in wrong direction!