弹性盒子应用:骰子

13 篇文章 0 订阅
13 篇文章 0 订阅
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>骰子</title>
  <style>
    div{
      width: 100px;
      height: 100px;
      background-color: gray;
      border: 1px solid black;
      float: left;
      display: flex;
      justify-content: space-between;
    }
    span{
      width: 25px;
      height: 25px;
      background-color: black;
      border-radius: 50%;
      display: inline-block;
      color: white;
      text-align: center;
    }
    /* 1点 */
    .one{
      justify-content: center;
    }
    .one>span{
      align-self: center;
    }
    /* 2点 */
    .two>span:nth-of-type(2){
      align-self: flex-end;
    }
    /* 3点 */
    .three>span:nth-of-type(2){
      align-self: center;
    }
    .three>span:nth-of-type(3){
      align-self: flex-end;
    }
    /* 4点 */
    .four{
      flex-wrap: wrap;
    }
    .four>span:nth-of-type(3){
      margin-right: 50px;
      align-self: end;
    }
    .four>span:nth-of-type(4){
      align-self: end;
    }
    /* 5点 */
    .five{
      flex-wrap: wrap;
      align-content: space-between;
    }
    .five>span:nth-of-type(3){
      margin: 0 37.5px;
    }
    /* 6点 */
    .six{
      flex-wrap: wrap;
      align-content: space-between;
    }
    .six>span:nth-of-type(2){
      margin: 0 12.5px;
    }
  </style>
</head>
<body>
  
  <div class="one">
    <span style="background-color: red;">1</span>
  </div>

  <div class="two">
    <span>1</span>
    <span>2</span>
  </div>

  <div class="three">
    <span>1</span>
    <span>2</span>
    <span>3</span>
  </div>

  <div class="four">
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
  </div>

  <div class="five">
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
    <span>5</span>
  </div>

  <div class="six">
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
    <span>5</span>
    <span>6</span>
  </div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值