0

I'm wondering how I can break the flex row and start a new one. I was hoping the display:flex would break it, but it does not.

wish

.dflex {
  display:flex;
}

.flexitem {
  flex:6;
}



/* irrelevant styles */

.dflex {
  border:2px solid red;
  margin:4px;
}

.flexitem {
  border:2px solid black;
  margin:4px;
}
<div class="dflex">
  <div class="flexitem">
    &nbsp;
  </div>
  <div class="flexitem">
    &nbsp;
  </div>
  <div class="dflex">
    <div class="flexitem">
      &nbsp;
    </div>
  </div>
</div>
Randy
  • 9,419
  • 5
  • 39
  • 56
  • Worth remembering that the `flex-grow` property does not necessarily equal width. - http://stackoverflow.com/questions/34733955/width-vs-flex-grow-in-flexbox – Paulie_D Jun 14 '16 at 15:38
  • 1
    _offtopic_, just out of curiosity: why you use `flex:6`? –  Jun 14 '16 at 15:44
  • @blonfu I'm trying to build my own grid System. For this `flex:1` would've worked, but elements have flex width based on the class. – Randy Jun 14 '16 at 15:47

1 Answers1

1

You can add flex-wrap: wrap; and width: 100%; to your .dflex class.

.dflex {
  display:flex;
  flex-wrap: wrap;
  width: 100%;
  border:2px solid red;
  margin:4px;
}

.flexitem {
  border:2px solid black;
  margin:4px;
  flex: 6;
}
<div class="dflex">
  <div class="flexitem">
    &nbsp;
  </div>
  <div class="flexitem">
    &nbsp;
  </div>
  <div class="dflex">
    <div class="flexitem">
      &nbsp;
    </div>
  </div>
</div>
Hunter Turner
  • 6,804
  • 11
  • 41
  • 56