实现特殊的循环布局

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      .box {
        column-count: 2;
        column-gap: 20px;
      }
      .list:first-child {
        height: 100%;
      }
      .list:not(:first-child) {
        height: calc(50% - 10px);
      }
      .list:not(:nth-child(2n -1)) {
        margin-bottom: 20px;
      }

      .self_box {
        display: grid;
        gap: 20px;
        grid-template-columns: repeat(2, calc(50% - 10px));
      }
      .item-1 {
        grid-row: 1 / 3;
      }
    </style>

    <script src="./vue/unocss.js"></script>
    <script src="./vue/vue.js"></script>
  </head>
  <body>
    <div id="app" class="grid place-items-center h-100vh w-100vw">
      <div class="h-400px w-800px box">
        <div v-for="(item,i) in list" class="list grid place-items-center text-80px" :class="item.bg">{{i}}</div>
      </div>

      <div class="h-400px w-800px self_box">
        <div v-for="(item,i) in list" class="grid place-items-center text-80px" :class="item.bg">{{i}}</div>
      </div>
    </div>

    <script>
      new Vue({
        el: '#app',

        data() {
          return {
            list: [
              {
                bg: 'item-1 bg-#ef342a',
              },
              {
                bg: 'bg-green',
              },
              {
                bg: 'bg-orange',
              },
            ],
          }
        },
        computed: {},
      })
    </script>
  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值