Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
create several separate themes (css files) with the names blue.css, red .css, pink.css and others at "css/colour-scheme/", and write links on the page
<a href="blue" class="new-colour blue" id="blue">blue</a>
<a href="purple" class="new-colour purple" id="purple">purple</a>
<a href="red" class="new-colour red" id="red">red</a>
<a href="green" class="new-colour green" id="green">green</a>
<a href="pink" class="new-colour pink" id="pink">pink</a>
<a href="orange" class="new-colour orange" id="orange">orange</a>
$(document).ready(function(){
"use strict";
$('.new-colour').click(function(e){
e.preventDefault();
var id = $(this).attr('href');
var style = ('#switch-style');
$(style).attr('href', 'css/colour-scheme/' + id + '.css');
$('.style-switcher').toggleClass('style-out');
});
$('.style-open').click(function(e){
e.preventDefault();
$('.style-switcher').toggleClass('style-out');
});
});
Elementary. Create 2 themes like this (it's best to use preprocessors like LESS/SASS/Stylus):
.theme_1 .header {background: #000;}
.theme_1 .button {background: #000;}
.theme_1 .link {color: #000;}
.theme_2 .header {background: #f00;}
.theme_2 .button {background: #f00;}
.theme_2 .link {color: #f00;}
<html class='theme_1'>
...
</html>
$(document).on('click', '.js-switch-theme', function () {
var theme = $(this).data('name'),
$html = $('html');
$html.removeClass();
$html.addClass(theme);
});
All on the redefinition of rules in css. In links - paths to individual css files.
Here is what is seen in the console when clicking on the colors:
GET
kudosthemes.co.uk/themes/launchify/launchify-image... [HTTP/1.1 200 OK 105ms]
GET
kudosthemes.co.uk/themes/launchify/launchify-image. .. [HTTP/1.1 200 OK 0ms]
GET
kudosthemes.co.uk/themes/launchify/launchify-image...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question