Is it possible, to use javascript to edit the contents of a .css file directly? (In turn, impacting the style of the elements that use the class being modified?)
I’ve seen a few answers to such a question, but they all deal with the dynamic creation of HTML and css code in the html document itself, which I don’t quite want…
Say for example, I have the following code:
*{
color:red;
}
This makes ALL the text in the document go red. If I give the client an option to drop down and change the color of all the text to whatever he/she wishes, then the most logical choice is for me to go into the .css file, and edit the value of ‘color’ under the universal selector…
Ideas?
You can do all your css manipulation in a single style element you append to the head-
anything you put there takes precedence over the other stylesheets, and your users can ‘backtrack’ to the page defaults by deleting their changes, one at a time or all at once.
Using the last sheet (your new style element’s rules) in the document.styleSheets collection, you can append new rules, delete old rules, or edit existing rules.
And you have a piece of text you can save on your server or in local storage for each user, possibly to add to the document the next time they visit.