利用flex布局实现骰子

在这里插入图片描述

<!DOCTYPE html>
<html>

   <head>
      <meta charset="UTF-8">
      <title></title>
      <style type="text/css">
      	.bg{
      		width: 300px;
      		height: 300px;
      		background-color: #000;
      		padding-top: 50px;;
      	}
      	.item{
      		display: block;
      		width: 20px;
      		height: 20px;
      		background-color: #000;
      		border-radius: 10px;
      	}
      	.box{
      		width: 105px;
      		height: 105px;
      		background-color: rgb(231,231,231);
      		margin: 0 50px;
      		border-radius: 20px;
      		padding: 5px 5px;
      		border: 6px solid rgb(215,215,215);
      		
      		/*一点*/
      		/*display: flex;*/  /*默认项目主轴对齐方式为左对齐  flex-start*/
      		/*justify-content: flex-end;*/  /*设置项目主轴对齐方式为右对齐*/
      		/*justify-content: center;*/ /*设置项目主轴对齐方式为居中对齐*/
      		/*align-items: flex-start; */  /*设置项目交叉轴对齐方式为上对齐*/
      		/*align-items: flex-end; */  /*设置项目交叉轴对齐方式为下对齐*/
      		/*align-items: center;*/   /*设置项目交叉轴对齐方式为居中对齐*/
      		
      		/*二点*/
      		/*display: flex;*/
      		/*justify-content: space-between;*/
      		
      		/*三点*/
      		/*display: flex;
      		justify-content: space-between;*/
      		
      		/*四点*/
      		display: flex;
      		flex-wrap: wrap;
      		justify-content: space-between;
      		
      		
      	}
      	/*二点*/
      	/*.item:nth-child(2){*/
      		/*align-self: flex-end; */  /*这个属性是用来定义单个元素*/
      	/*}*/ 
      	
      	
      	/*三点*/
      	/*.item:nth-child(2){
      		align-self: center;
      	}
      	.item:nth-child(3){
      		align-self: flex-end;
      	}*/
      	
      	/*四、五、六、七、八、九点*/
      	.column{
      		flex-basis: 100%; 
      		display: flex;
      		justify-content: space-between;
      	}
      	
      	.column:nth-child(2){
      		justify-content: center;
      		margin-top: -20px;
      	}
      	.column:nth-child(3){
      		justify-content: flex-end;
      		margin-top: -20px;
      	}
      	.column:nth-child(5){
      		align-self: flex-end;
      	}
      	.column:nth-child(4){
      		align-self: center;
      		/*justify-content: center;*/
      	}
      </style>
   </head>

   <body>
   <div class="bg">
	   <div class="box">
		   	<div class="column">
		      	<span class="item"></span>
		   	</div>
		   	<div class="column">
		      	<span class="item"></span>
		   	</div>
		   	<div class="column">
		      	<span class="item"></span>
		   	</div>
		   	<div class="column">
		   		<span class="item"></span>
		   		<span class="item"></span>
		   	</div>
		   	<div class="column">
		   		<span class="item"></span>
		      	<span class="item"></span>
		   	</div>
	   </div>
	</div>
   </body>

</html>
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值