变色九宫格

变色九宫格

<!doctype html>
<html>
<head>
<meta content="1" http-equiv="refresh"><!--content用来设置闪光时间,单位是秒。http-equiv="refresh"实现网页自动跳转-->
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body bgcolor="#000">
<script>
	function color_(){ //Math.floor(Math.random()*16777215)是在该整数范围内随机选择一个值,而Math.floor()是执行向下舍入,即它总是将数值向下舍入为最接近的整数。最后执行.toString(16)将随机整数转化为16进制。
		return"#"+Math.floor(Math.random()*16777215).toString(16);//收集一个函数:获取颜色随机值。16777215为16进制的颜色ffffff转化为10进制的数字。 
	}
	document.write("<div style='width:156px;height:156px;margin:0 auto; background:#FBF7F7;padding:1px;'>");//设置背景边框大小,margin:0 auto:div在浏览器中布局居中,水平居中。设置颜色。padding:四周边距1像素(内边距)。
		for(i=1;i<10;i++){//for循环出现9个。
			document.write("<div style='width:50px;height:50px;margin:1px;background:"+color_()+";float:left;'>");//for循环中的9个方块进行设置边框大小,颜色,margin:外边距,float:浮动。
							document.write("</div>");//输出9个方块。

			}
				document.write("</div>");//输出背景边框。
</script>
<div>
	<div></div><!--div嵌套div实现九宫格样式-->
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值