0

I have a flexbox layout which has a scrollable area. This is how it should look:

as it should look like

The green section is meant to be twice as large as the yellow one.

The element which makes troubles is the right-most one. If the scrollable area contains large elements (e.g. 1000px), it breaks my layout and looks like this: (Edit: this is true for Firefox and Chrome - IE works)

as it looks like

I have created a Plunker for you to see my code:

http://plnkr.co/edit/OnYZ8o8fzvkonW39oema?p=preview

Here is the same code as in the Plunker...

<div class="container">
  <div class="left">
    LEFT
  </div>
  <div class="right">
      <div class="fullheight">
        100% Height using flex-boxes
      </div>
      <div class="fullheight">
        <big>... scrollable<br />... scrollable<br />... scrollable</big>
        <big>... scrollable<br />... scrollable<br />... scrollable</big>
      </div> 
      <div class="fullheight noscroll">
        <header>Header</header>
        <div class="scrollcontainer">
          <div class="somethingbig">Something big</div>
        </div>
      </div> 
  </div>
</div>

The CSS:

.container {
  display:flex;
  flex:1 1 auto;
  flex-direction:row;
  background:#fcc;
  padding: 3px;
  margin-bottom:20px;
  /*height:200px;*/
}
.left, .right {
  flex:1 1 1px;
  background:#ffc;
  padding: 3px;
  margin:3px;
}
.right {
  display:flex;
  flex:2 2 1px;
  background:#ccffcc;
}
.right > .fullheight {
  flex:1 1 1px;
  border: 1px solid red;
  overflow:auto;
  display:flex;
}
.fullheight.noscroll {
  display:flex;
  flex-direction:column;
}
.scrollcontainer {
  overflow:auto;
}
Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
ESP32
  • 8,089
  • 2
  • 40
  • 61
  • A flex item, by default, cannot be smaller than the length of its content. Add `min-width: 0` to `.right`, and other flex items, as necessary. – Michael Benjamin Aug 29 '16 at 13:34
  • @Michael_B - min-width works - thank you. Can you explain this please? – ESP32 Aug 29 '16 at 13:36
  • I agree that the solution in the "dupe" is the same, however as I use overflow:auto it's not obvious to me. – ESP32 Aug 29 '16 at 13:40
  • That's a good point. However, `.right`, which is the flex item at issue here, is actually `overflow: visible`. It is the children of this flex item that have `overflow: auto`. – Michael Benjamin Aug 29 '16 at 13:49

0 Answers0