I would like someone to tell me what's the code for making a webpage background color (the background color of the whole page) to change (fade transition) every 30s to a given color variety. Is it simple? I guess css will make it easier?
I've searched over the internet and I only found gradients which is not what I want. Thank you in advance. I 've search codepen and jsfiffle for examples but no one had something that simple :/
Example: While browsing my page I want the background color to change from blue to green and then to orange and again blue and so on so on... :)
Here's a jQuery approach, to complete Bogdan's answer, that takes 3 parameters:
selector
(example, ".container" or "div"),colors
(an array of colors to switch in between) andtime
(controls how frequently the bgd color changes). I set it for 3 seconds (3000
) so you can see it in action easier, but you can increase it to 30000 (30 seconds).It's also possible to do this without any JavaScript at all, using CSS3 animations.
Something like this fiddle
CSS:
Javascript: