如何将弹性项目分成移动列?

obr*_*ezy 3 html css flexbox

我正在使用 flex 并且我有 4 列。我将如何打破它让 2 并排移动?

我的笔:http : //codepen.io/omarel/pen/PpPXao

.flexparent {
  display: -webkit-flex;
  display: flex;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  justify-content: center;
}

.flexparent .flexchild {
  width: 30%;
}
Run Code Online (Sandbox Code Playgroud)
<div class="flexparent">
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-trains.png" alt="">
    <h2>Col 1</h2>

  </div>
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-events.png" alt="">
    <h2>Col 2</h2>

  </div>
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-parks.png" alt="">
    <h2>Col 3</h2>
  </div>
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-walk.png" alt="">
    <h2>Col 4</h2>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Mic*_*ker 5

将父级设置为flex-wrap: wrap;,将子级设置width: 50%为每行 2 个。

.flexparent {
  display: -webkit-flex;
  display: flex;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  justify-content: center;
}

.flexparent .flexchild {
  width: 30%;
}

@media (max-width: 420px) {
  .flexparent {
    flex-wrap: wrap;
  }
  .flexparent .flexchild {
    width: 50%;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div class="flexparent">
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-trains.png" alt="">
    <h2>Col 1</h2>

  </div>
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-events.png" alt="">
    <h2>Col 2</h2>

  </div>
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-parks.png" alt="">
    <h2>Col 3</h2>
  </div>
  <div class="flexchild">
    <img src="../images/new/mw/icons/icon-walk.png" alt="">
    <h2>Col 4</h2>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)