作者:
链接:http://proprogrammar.com:443/article/826
声明:请尊重原作者的劳动,如需转载请注明出处
whimurmur帮助文档中的内容背景
先看代码
colors = [parseInt(Math.random()*256),parseInt(Math.random()*4) * 2 + 2,parseInt(Math.random()*256),parseInt(Math.random()*4) * 2 + 2,parseInt(Math.random()*256),parseInt(Math.random()*4) * 2 + 2];
function initChangingBg(){
$(".cl-artical-content").css("background-color", 'rgba(' + colors[0] + ', ' + colors[2] + ', ' + colors[4] + ', 0.5)');
for(var i = 0; i < 6; i += 2){
(colors[i] + colors[i+1] > 255 && (colors[i+1] = -parseInt(Math.random()*4) * 2 - 2)) || (colors[i] + colors[i+1] < 0 && (colors[i+1] = parseInt(Math.random()*4) * 2 + 2));
colors[i] += colors[i+1];
}
setTimeout(initChangingBg, 100);
}
initChangingBg();
再看效果
亲爱的读者:有时间可以点赞评论一下
全部评论