7

I have two divs:

  1. top div contains a long text that takes up several lines
  2. lower div has min-height and flex-grow: 1

When I reducing the window to the scroll appeared, then in chrome everything is displayed correctly. But in IE11 top div is reduced to one line, and its text is on top of the bottom div.

I can fix it only with set some width for content of top div (it work with fixed width, or calc width, but not work with percentage width) How can I fix it without setting width or with percentage width (width:100%)?

body,
html {
  height: 99%;
  padding: 0;
  margin: 0;
}

.flexcontainer {
  width: 25%;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid lime;
}

.allspace {
  flex-grow: 1;
  min-height: 300px;
  background-color: yellow;
}

.longtext {
  background-color: red;
}

.textcontainer {
  border: 1px solid magenta;
  /*IE work correctly only when specified width. by example: width:calc(25vw - 2px);*/
}
<div class="flexcontainer">
  <div class="longtext">
    section 1 with long name section 1 with long name section 1 with long name
  </div>
  <div class="allspace">
    all space
  </div>
</div>

jsfiddle: https://jsfiddle.net/tkuu28gs/14/

Chrome:

enter image description here

IE11:

enter image description here

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
JIemON
  • 377
  • 1
  • 6
  • 19
  • Have you tried using 'height' instead of 'min-height'? IE11 has issues when using both display: flex and a min-height on a child element. – MumfordJw Mar 19 '18 at 15:06
  • in ie11, the issue also produced with the fixed height of the child div and without specifying the height of the child – JIemON Mar 19 '18 at 15:28
  • encountered a similar issue. but my child flex item has nested elements which is flex too. the fix was just to set a height on the inner child elements. if you forget the height, things get messy :) – mars-o Sep 23 '20 at 10:56

3 Answers3

24

IE11 is full of flex bugs and inconsistencies with other browsers.

In this case, the source of the problem is flex-shrink.

IE11 is rendering flex items oddly after applying flex-shrink: 1 (a default setting), which causes the lower item to overlap its sibling above. This problem doesn't occur in other major browsers.

The solution is to disable flex-shrink. It fixes the problem in IE11 without changing anything in other browsers.

Add this to your code:

.longtext {
    flex-shrink: 0;
}

revised fiddle


You may also want to look into:

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
1

The use of flex-shrink: 0; mentioned in the accepted answer works to prevent overlapping. However, I'm using like flex: 0 1 15% as I intend to allow shrinking and this renders nicely in other browsers like MS Edge, Chrome, and Firefox, but not in IE 11.

To apply no shrinking (flex-shrink: 0) only for IE 11, I used the following instead as the -ms- is vendor-specific:

-ms-flex-negative: 0 !important;
Kenston Choi
  • 2,862
  • 1
  • 27
  • 37
-1

problem solved:

  body, html {
    height: 100vh;
    padding:0;
    margin:0;
}
.flexcontainer{
  width:25%;
  display: flex;
height: 100%;
  flex-flow: column;
  border: 1px solid lime;
}
.allspace{
  flex-grow:1;
  background-color: yellow;
}
.longtext{
  background-color: red;
  //EDIT
  flex-grow: 0;
  min-height: 100px;
}
.textcontainer{
  border:1px solid magenta;
  /*IE work correctly only when specified width. by example: width:calc(25vw - 2px);*/
}

EDIT (screenshots on IE11)

enter image description here

enter image description here

sikarak
  • 88
  • 8
  • no, it work only without min-width, and if you reduce the window to the size of the top div, then the problem is the same: https://image.ibb.co/nJV2Xx/ie11.png – JIemON Mar 19 '18 at 15:22
  • so try modify that to my previous code: .longtext{ min-height:100px; flex-grow: 0; background-color: red; } – sikarak Mar 19 '18 at 15:29
  • can You post jsfiddle, because it seems to me that this solution is with fixed min-height of the upper div, and I need the top div with auto-height according to its content, and the bottom div with fixed min-height – JIemON Mar 19 '18 at 16:09