首页 > 其他 > 详细

rgb随机变色

时间:2016-03-17 19:21:30      阅读:248      评论:0      收藏:0      [点我收藏+]

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>rgb随机生成色</title>
<style type="text/css">
#div1{
height:100px;width:100px;margin:10px auto;background:red;
}
</style>
<script type="text/javascript">
function color(){
var r=parseInt(Math.random()*255);
var g=parseInt(Math.random()*255);
var b=parseInt(Math.random()*255);
var newcolor="rgb("+r+","+g+","+b+")";
return newcolor;
}
window.onload =function (){
var odiv=document.getElementById(‘div1‘);
setInterval (function (){
var c=color();
odiv.style.backgroundColor=c;
},50);
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>

rgb随机变色

原文:http://www.cnblogs.com/ll-taj/p/5288676.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!