Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

Background: Connected to a project of the Internet of things, write the front end by myself, and use Grid layout.

A simple 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;
    }
Copy the code
CSS style effects

index.html

<! DOCTYPEhtml>
<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">Real-time data</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">Real-time data</p>
        <p class="l-items">Real-time data</p>
      </div>

      <div class="container-r">
        <div class="container-r-top">
          <p>Real-time data</p>
        </div>

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

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

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

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

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

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


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


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

</html>
Copy the code