jquery - How to set SASS variable using javascript -


i want set global variable in css using sass css. global variable must set using javascript. how set variable using javascript or other method have use root css not supported ie browser. following css

$mainbgimage: image url; .page-title { padding: 0; min-height: 200px; background-image: $mainbgimage; } 

scss , preprocessed languages. bring features (like variables) make easier develop , maintain styles. features not supported vanilla css , need run preprocessor (sass) generate css browsers support.

the resulting css has no variables hence cannot change them client side javascript directly.

but fortunately have plenty of options dynamic styles. i'd recommend toggling css classes so:

document.getelementbyid('elementid').classlist.add('specialstyleclass');  /* ... */  document.getelementbyid('elementid').classlist.remove('specialstyleclass'); 

you can set element styles directly javascript:

document.getelementbyid('elementid').style.color = 'red'; 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -