【问题标题】:Remove vertical spacing from flex-wrap:wrap property [duplicate]从 flex-wrap:wrap 属性中删除垂直间距 [重复]
【发布时间】:2021-09-14 12:00:53
【问题描述】:

我在这里有这个plunkr。使用flex-wrap: wrap;时如何去掉垂直间距@

#main {
  width: 200px;
  height: 200px;
  border: 1px solid #c3c3c3;
  display: flex;
  flex-wrap: wrap;
}
<div id="main">
  <div style="background-color:coral;">A</div>
  <div style="background-color:lightblue;">B</div>
  <div style="background-color:khaki;">C</div>
  <div style="background-color:pink;">D</div>
  <div style="background-color:lightgrey;">E</div>
  <div style="background-color:lightgreen;">F</div>
</div>

【问题讨论】:

  • align-content: flex-start;#main
  • 从#main css 块中移除高度属性 css

标签: html css flexbox


【解决方案1】:

你应该在#main上使用align-content: flex-start;

【讨论】:

    【解决方案2】:

    #main {
      width: 200px;
      height: 200px;
      border: 1px solid #c3c3c3;
      display: flex;
      flex-wrap: wrap;
      align-content: flex-start;
    }
    <div id="main">
      <div style="background-color:coral;">A</div>
      <div style="background-color:lightblue;">B</div>
      <div style="background-color:khaki;">C</div>
      <div style="background-color:pink;">D</div>
      <div style="background-color:lightgrey;">E</div>
      <div style="background-color:lightgreen;">F</div>
    </div>

    【讨论】:

      猜你喜欢
      • 2018-02-03
      • 1970-01-01
      • 2013-07-01
      • 2023-01-04
      • 2013-07-20
      • 2012-03-09
      • 1970-01-01
      • 2021-09-04
      • 2023-03-28
      相关资源
      最近更新 更多