css3-grid制作骰子

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
		<style type="text/css">
			/* 第一个骰子样式 */
			.box{
				width: 100px; height: 100px; border: 1px black solid; border-radius: 5px;
				display: grid; grid-template-columns: repeat(3,1fr);grid-template-rows: repeat(3,1fr);
				place-items: center center;
				}
			.box div{
				width: 20px; height: 20px; background: black; border-radius: 50%;
				}
			.box div:nth-child(1){grid-area: 2/2/3/3;}
			/* 第二个骰子样式 */
			.box1{
				width: 100px; height: 100px; border: 1px black solid; border-radius: 5px;
				display: grid; grid-template-columns: repeat(3,1fr);grid-template-rows: repeat(3,1fr);
				place-items: center center;
				}
			.box1 div{
				width: 20px; height: 20px; background: black; border-radius: 50%;
				}
			.box1 div:nth-child(2){grid-area:3/3/4/4;}
			/* 第三个骰子样式 */
			.box2{
				width: 100px; height: 100px; border: 1px black solid; border-radius: 5px;
				display: grid; grid-template-columns: repeat(3,1fr);grid-template-rows: repeat(3,1fr);
				place-items: center center;
				grid-template-areas: 
				"a1 a2 a3"
				"a4 a5 a6"
				"a7 a8 a9";
				}
			.box2 div{width: 20px; height: 20px; background: black; border-radius: 50%;}
			.box2 div:nth-child(2){grid-area: a5;}
			.box2 div:nth-child(3){grid-area: a9;}
			/* 第四个骰子样式 */
			.box3{
				width: 100px; height: 100px; border: 1px black solid; border-radius: 5px;
				display: grid; grid-template-columns: repeat(3,1fr);grid-template-rows: repeat(3,1fr);
				place-items: center center;
				grid-template-areas: 
				"a1 a2 a3"
				"a4 a5 a6"
				"a7 a8 a9";
				}
			.box3 div{width: 20px; height: 20px; background: black; border-radius: 50%;}
			.box3 div:nth-child(2){grid-area: a3;}
			.box3 div:nth-child(3){grid-area: a7;}
			.box3 div:nth-child(4){grid-area: a9;}
			/* 第五个骰子样式 */
			.box4{
				width: 100px; height: 100px; border: 1px black solid; border-radius: 5px;
				display: grid; grid-template-columns: repeat(3,1fr);grid-template-rows: repeat(3,1fr);
				place-items: center center;
				grid-template-areas: 
				"a1 a2 a3"
				"a4 a5 a6"
				"a7 a8 a9";
				}
			.box4 div{width: 20px; height: 20px; background: black; border-radius: 50%;}
			.box4 div:nth-child(2){grid-area: a3;}
			.box4 div:nth-child(3){grid-area: a7;}
			.box4 div:nth-child(4){grid-area: a9;}
			.box4 div:nth-child(5){grid-area: a5;}
			/* 第六个骰子样式 */
			.box5{
				width: 100px; height: 100px; border: 1px black solid; border-radius: 5px;
				display: grid; grid-template-columns: repeat(3,1fr);grid-template-rows: repeat(3,1fr);
				place-items: center center;
				grid-template-areas: 
				"a1 a2 a3"
				"a4 a5 a6"
				"a7 a8 a9";
				}
			.box5 div{width: 20px; height: 20px; background: black; border-radius: 50%;}
			.box5 div:nth-child(2){grid-area: a3;}
			.box5 div:nth-child(3){grid-area: a7;}
			.box5 div:nth-child(4){grid-area: a9;}
			.box5 div:nth-child(5){grid-area: a4;}
			.box5 div:nth-child(6){grid-area: a6;}
		</style>
	</head>
	<body>
		<div class="box">
			<div></div>
		</div>
		<div class="box1">
			<div></div>
			<div></div>
		</div>
		<div class="box2">
			<div></div>
			<div></div>
			<div></div>
		</div>
		<div class="box3">
			<div></div>
			<div></div>
			<div></div>
			<div></div>
		</div>
		<div class="box4">
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
		</div>
		<div class="box5">
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
		</div>
	</body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值