0

I have a popup that I'm trying to vertically align in the page, I use flex (align-items) to do this but it doesn't work for IE11. After some research I found there is a bug in IE11 where align-items doesn't' work well with min-height. I already tried some of the solutions given but nothing seems to work.

What I tried:

  1. Replacing the min-height by height on the popup-inner-wrapper
  2. Maintain the min-height and add height of 1px

Output:

  1. Centers everything correctly (chrome and IE) but only when there is little content. If you add more text to the example you will see that the top part of the popup is cut
  2. Same thing happens as in 1

Example of the code HERE

.popup-wrapper {
  height: 100vh;
  overflow: hidden;
  overflow-y: auto;
  transform: translateZ(0);
  -webkit-overflow-scrolling: touch;
}

.popup-inner-wrapper {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  display: flex;
  transform: translateZ(0);
}
<div class="popup-mask">
  <div class="popup-wrapper">
    <div class="popup-inner-wrapper">
      <div class="popup-container ">
        <div class="popup-content">
          (text)
        </div>
      </div>
    </div>
  </div>
</div>

3
  • For my understanding: You want an Area in the middle of the Screen where text is displayed right? so that it doesnt get placed at the top or the bottom cause of IE11 Problems?
    – Warden330
    Commented Jul 14, 2020 at 11:26
  • @Warden330 No, I want an area in the middle where text is displayed, however the current solution does not center the area vertically on IE11
    – user9875
    Commented Jul 14, 2020 at 11:49
  • stackoverflow.com/questions/40775317/… Does this help you? Thats what i usually do when i get aligning problems in IE11. Using % for the parent Container and make it Flex, or i put invisible spacer-divs above and beyond the content area to manually adjust the alignment on the site
    – Warden330
    Commented Jul 14, 2020 at 12:12

1 Answer 1

0

It's a known issue of IE. The min-height property will not work when used with Flexbox layout in IE. We can use css-tricks to fix it in IE. Give the parent a flex column container in Flexbox layout.

CSS of parent in Flexbox layout:

display: flex;
flex-direction: column;

In your code, you should change the .popup-wrapper style like below:

.popup-wrapper {
    height: 100vh;
    overflow: hidden;
    overflow-y: auto;
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
    flex-direction: column;
    display: flex;
 }

Result in IE 11:

enter image description here

2
  • This works for small popups but if the content increases the popup gets cut at the top
    – user9875
    Commented Jul 15, 2020 at 8:54
  • If the content is long then you can just use your original code and the results are the same in IE and in other browsers. You should choose what code to use according to your content length.
    – Yu Zhou
    Commented Jul 15, 2020 at 9:40

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