我需要一点帮助。

我想像图像中那样创建盒子模型,有人可以帮我吗。

我已经写过代码,但是我不知道如何做得更好。

image



.container {
  display: flex;
  justify-content: flex-start;
  flex-direction: row;
  flex-wrap: wrap;
}

.card {
 background: #cecdcd;
  color: #000;
  position: relative;
  width: 110px;
  height: 110px;
  margin: 10px;
  overflow: hidden;
  word-wrap: break-word;
  border-radius: 10px;
  transition: 200ms;
}

<div class="container">
  <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
   <div class="card">
  </div>
</div>

最佳答案

像这样吗
https://codepen.io/hisbvdis/pen/rNBYyJy



.container {
  display: flex;
  justify-content: flex-start;
  flex-direction: row;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid #000;
}

.card {
  flex-basis: calc((100% - 60px) / 3);
  background: #cecdcd;
  color: #000;
  position: relative;
  /* width: 110px; */
  height: 110px;
  margin: 10px;
  overflow: hidden;
  word-wrap: break-word;
  border-radius: 10px;
  transition: 200ms;
}

<div class="container">
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
  <div class="card">
  </div>
</div>

09-25 17:29