开发者

Chameleon site, changing site's color with the color selector

I want to learn how can i design a site which background and images color will be changeable by the user. Colors could change by only one color within 4 colors such as green, blue, white etc. in the sites such as msn, yahoo etc. But, there was no effects like 开发者_如何学Pythondrop shadow or gradient overlay in that images. However, I want to change color of images which applied effects such as drop shadow, gradient overlay. Moreover, with each color. Just like chameleon.

I can put a text link on the right of the top. A color selector like at Photoshop can open, when the user clicked this link. Color selector generates a hex code according to selected color. Color of site changes to color which the user selected.

I changed an image background color which is transparent by using JavaScript DOM. Color of transparent area in the image will be the same with the background color of div tag which contains this image. But, if the image has got effects like shadow, overlay etc., the changing color will be disable.

How can I do it, and which technology will I use, jQuery, Ajax? How I create a site which color could change.How I create a site which color will be changeable by the user.

Just like chameleon...


Hmm, well this might take a while to implement, if you're starting with little knowledge.

My suggestion, to get you started, is to have a javascript which changes the class of the body element according to a selection the user makes. So let's say I visit the page, the <body> tag has no class, and default css is used.

Then I click on the link to make things red. Using javascript, or jquery, give the body the class "red-body".

Have css in your stylesheet which only works for elements which are children of an element with this class.

Html:
<a href="" class="go-red">Go Red</a>

jQuery
$('.go-red').click(function(){$('body').removeClass();$('body').addClass('red-body');});

So if you have code like:

#navigation li{color:#000;}
.red-body #navigation li{color: #af000;}

This will make this possible. This means you can do it all with just one stylesheet, which I think is the best way.

There are a number of ways to store the users choice. One of the easiest ways is to set a cookie in their browser. You can do this with javascript, here's the introduction from w3schools: http://www.w3schools.com/JS/js_cookies.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜