0

how can I enable scroll for flex column child, when flex column has max-height and contained in flex container ?

I've got an example here https://codepen.io/ChatduChesire/pen/vYKVJoR

When .modal-wrapper contains align-items:center; or any other value for align-items there is no scroll for .modal-content in IE11, when I remove align-items everything works fine. I need .modal has limited height when it overflows, but fluid when in doesn't.

1 Answer 1

1

I suggest you try to replace the overflow: hidden; with overflow: auto; in the .model class will help to fix the issue in the IE 11 browser.

.modal-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

.modal-wrapper {
  display:flex;
  align-items:center;
  height: 100%;
}

.align-top {
  align-items: flex-start;
}

.modal {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-height: 25%;
  border: 1px solid red;
  overflow: auto;
}

.modal-content {
  flex: 1 1 auto;
  overflow: auto;
  min-height:0;
}
.header, footer {
  flex: 0 0 auto;
}
<div class="modal-overlay">
<div class="modal-wrapper">
  <div class="modal">
    <header>Header</header>

    <div class="modal-content">
    
        <ul>
          <li>Item</li>
           <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
            <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
            <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
            <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
          <li>Item</li>
        </ul>
    
    </div>
    <footer>Footer</footer>
  </div>
</div>
</div>

Output in the IE 11 browser:

  • Output when there are many list elements(will show the scrollbar).

enter image description here

  • Output when there are less or only one element(show the height properly).

enter image description here

2
  • Hi, thank you for your response! I've tried solution with height, but unfortunately this is now what I need cause when there is only one item, height keeps 25%, but I need height of content
    – Max Ivanov
    Commented Nov 19, 2020 at 19:38
  • @MaxIvanov, please check the updated answer. I have modified the answer as per your requirement. It can help to fix the issue. Thanks for your understanding. Commented Nov 20, 2020 at 7:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.