CSS Grid网格布局浅尝

技术源于生活,服务生活

地址:api.imibi.cn:8080

简单的Grid

  .container-r-btm {
      display: grid;
      /* grid-template-columns: repeat(auto-fill, 160px);
      grid-template-rows: repeat(auto-fill, 160px); */
      grid-template-columns: repeat(5, 1fr);
      grid-template-rows: repeat(auto-fill, 160px);
      grid-gap: 10px;
      /* gir */
      min-height: 200px;
      background-color: rgba(240, 240, 240, 0.3);
      padding: 20px;
    }

CSS样式效果

index.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .main {
      width: 94vw;
      min-height: 100vh;
      margin: 0 auto;
      background-color: snow;
    }

    .main-title {
      height: 60px;
      line-height: 60px;
      font-weight: normal;
    }

    .container {
      width: 100%;
      height: 100%;
      border: 1px solid #e5e5e5;
      display: flex;
    }

    .container-l {
      width: 300px;
      min-height: 200px;
      padding-left: 20px;
      padding-top: 20px;
      background-color: #fff;
    }

    .container-l .container-l-title {
      display: flex;
      align-items: center;
      margin-bottom: 12px;
    }

    .container-l .container-l-title img {
      width: 40px;
      height: 40px;
      margin-right: 10px;
    }

    .container-l .container-l-title p {
      font-size: 36px;
      color: blue;
      font-weight: bold;
    }

    .l-items {
      padding: 10px;
    }

    .container-r {
      padding-top: 20px;
      background-color: #fff;
      min-height: 200px;
      flex: 1;
    }

    .container-r-btm {
      display: grid;
      /* grid-template-columns: repeat(auto-fill, 160px);
      grid-template-rows: repeat(auto-fill, 160px); */
      grid-template-columns: repeat(5, 1fr);
      grid-template-rows: repeat(auto-fill, 160px);
      grid-gap: 10px;
      /* gir */
      min-height: 200px;
      background-color: rgba(240, 240, 240, 0.3);
      padding: 20px;
    }

    .box-items {
      /* width: 140px;
      height: 140px; */
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background-color: #fff;
    }

    .box-items img {
      width: 40px;
      height: 40px;
    }

    .box-items p {
      margin-bottom: 12px;
    }
  </style>
</head>

<body>
  <div class="main">
    <h2 class="main-title">实时数据</h2>

    <div class="container">
      <div class="container-l">
        <div class="container-l-title">
          <img src="./src/img/haha.png" alt="">
          <p>RANK</p>
        </div>
        <p class="l-items">实时数据</p>
        <p class="l-items">实时数据</p>
      </div>

      <div class="container-r">
        <div class="container-r-top">
          <p>实时数据</p>
        </div>

        <div class="container-r-btm">
          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>

          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>

          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>

          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>

          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>

          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>


          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>


          <div class="box-items">
            <p>30</p>
            <p>温度C</p>
            <img src="./src/img/haha.png" alt="">
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值