+ 1
How would i code a button that could change the theme color of a website or html document?
11 Respostas
+ 5
I made this theme changer in jq b4, all I would do is put in words like #theme, #theme-dark, #theme-light etc into my css (internal) in place of color values
.mytheme {
background-color: #theme;
}
I had a color dropdown menu with predefined colors on it, then in jq I got the text from the style tag and replaced those values with color codes(for the dropdown selection), then set the new css a the pages css and it would work, but a problem with it was it would only change if I would refresh the page....probably not the best way to do that but it worked...sorta
+ 5
yeah I get that, hard to do complex stuff without knowing what ur doing lol
+ 4
you could set each theme color to separate classes (background, text, border etc) and then use those classes in ur html and change the class names in JavaScript
+ 3
Check this link:
https://alistapart.com/article/alternate
It talk about XHtml, but would be still valid for Html, at least for understanding how to handle alternate style sheet with JS ;)
+ 1
JavaScript is the best and simple options
+ 1
if u understand the theory then it will become easier for you to write the codes...in your preferred language
0
I'll have to try that.
0
would it be easier to make a copy of the css document with different themes and just use an a tag in a button to load different themes?
0
yeah but im still just trying to get the hang of JavaScript. i understand it in theory but have litte practice.
0
Right, i just found a video that shows how to change the css link by giving it an id and passing it threw a JavaScript function, it kinda helps but its still to vague.
0
I am a beginner .sorry