search

Home  >  Q&A  >  body text

How to put the inner div of a nested div structure into a new row using flex box?

I want the inner div (Mem 3) in a new row, below Mem 1, and I don't want to change the div structure at all costs. please help.

Like this =>

.flex-container {
  display: flex;
  flex-wrap: wrap;
}

.flex-child {
  border: solid blue;
}

.flex-fgc {
  border: solid blue;
}

.flex-inner-gc {
  border: solid blue;
}
<div class='flex-container'>
  <div class='flex-child'>
    Mem 1
  </div>
  <div class='flex-fgc'>
    <div>
      Mem 2
    </div>
    <div class='flex-inner-gc'>
      Mem 3
    </div>
  </div>
</div>

I tried "flex: 1 1 100;" for flex-inner-gc.

P粉982054449P粉982054449560 days ago667

reply all(1)I'll reply

  • P粉190883225

    P粉1908832252023-09-14 11:32:36

    float can easily do this.

    .flex-child {
      border: solid blue;
      float: left;
    }
    
    .flex-fgc > * {
      float: left;
      border: solid blue;
    }
    
    .flex-inner-gc {
      clear: both;
    }
    <div class='flex-container'>
      <div class='flex-child'>
        Mem 1
      </div>
      <div class='flex-fgc'>
        <div>
          Mem 2
        </div>
        <div class='flex-inner-gc'>
          Mem 3
        </div>
      </div>
    </div>

    reply
    0
  • Cancelreply