flex布局实现骰子六面的示例

显示效果:
在这里插入图片描述

下面是示例代码:

<html>
  <head>
    <title>flex布局-骰子</title>
    <style>
      body {
        background-color: tan;
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
      }
      .box {
        background-color: white;
        border-radius: 10px;
        width: 75px;
        height: 75px;
        display: flex;
        margin: 10px;
        padding: 10px;
      }
      .item {
        background-color: darkblue;
        border-radius: 10px;
        width: 20px;
        height: 20px;
      }

      .box1 {
        justify-content: center;
        align-items: center;
      }
      .box1 .item {
        background-color: red;
        border-radius: 15px;
        width: 30px;
        height: 30px;
      }

      .box2 {
        justify-content: space-around;
        align-items: center;
      }

      .box3 {
        justify-content: space-around;
      }
      .box3 .item:nth-child(2) {
        align-self: center;
      }
      .box3 .item:nth-child(3) {
        align-self: flex-end;
      }

      .box4 {
        flex-wrap: wrap;
        align-content: space-around;
      }
      .box4 .column {
        flex-basis: 100%;
        display: flex;
        justify-content: space-around;
      }
      .box4 .item {
        background-color: red;
      }

      .box5 {
        flex-wrap: wrap;
        align-content: space-between;
      }
      .box5 .column {
        flex-basis: 100%;
        display: flex;
        justify-content: space-between;
      }
      .box5 .column:nth-child(2) {
        justify-content: center;
      }
      .box5 .item {
        margin: 2px;
      }

      .box6 {
        flex-wrap: wrap;
        justify-content: space-around;
        align-content: space-around;
      }
    </style>
  </head>
  <body>
    <div class="box box1">
      <span class="item"></span>
    </div>

    <div class="box box2">
      <span class="item"></span>
      <span class="item"></span>
    </div>

    <div class="box box3">
      <span class="item"></span>
      <span class="item"></span>
      <span class="item"></span>
    </div>

    <div class="box box4">
      <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 class="box box5">
      <div class="column">
        <span class="item"></span>
        <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>

    <div class="box box6">
      <span class="item"></span>
      <span class="item"></span>
      <span class="item"></span>
      <span class="item"></span>
      <span class="item"></span>
      <span class="item"></span>
    </div>
  </body>
</html>
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值