好吧,就在这里。
简单地说,我希望能够通过 CSS 淡出身体的背景并经常改变然后循环。
有什么想法可以通过 CSS 和 jQuery 实现吗?
谢谢!
好吧,就在这里。
简单地说,我希望能够通过 CSS 淡出身体的背景并经常改变然后循环。
有什么想法可以通过 CSS 和 jQuery 实现吗?
谢谢!
您可以使用 jquery animate 方法,并在完成时使用新颜色再次调用该方法:
var color = ["red","green","blue"];
var i = 0;
function changeColor()
{
// Change to the next color over 2 seconds. When it is done, call this method again.
$("body").animate({"background-color":color[i]}, 2000, changeColor);
i++; // Increment the counter so the next color in the array is shown
i = i % 3; // Make sure i is never greater than 2 by using the modulous.
}
changeColor();
看到这个小提琴:http: //jsfiddle.net/johnkoer/vDCSw/5/
</p>