How to implement adaptive grid layout?

the following layout rules
clipboard.png

  1. .line-block (small blue blocks) quantity, variable width and height
  2. .container (container) variable width
  3. .line-block align to the left in the line, starting to the left in the whole
  4. in .cantainer aligns in the middle of the behavior unit
  5. .cantainer Vertical orientation is top alignment, unequal space

flex and grid are not very familiar with the layout, try to use, but always meet part, not really satisfied, ask the bosses

Jul.04,2022

set a padding on the outside, and fill it automatically with flex inside


<div class="container">
  <div class="flex">
    <div class="line-block"></div>
    <div class="line-block"></div>
  </div>
</div>

.container {
  width: 400px;
  height: 400px;
  background-color: gray;
}
.flex {
  display: flex;
  flex-wrap: wrap;
}

.line-block {
 margin: 10px;
 width: 30px;
 height: 30px;
 background-color: blue;
}

effect:
clipboard.png


Boss, have you solved it? I also encountered the same problem

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bc9875-38d44.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bc9875-38d44.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?