Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex items exceed width of parent in IE

I have a ul > li > a > img parenthesis and am using flexbox to align all list items on to a single row whilst the images are maintaining their aspect ratio's.

What it looks like in Chrome 45, Firefox 40, Safari 8, Opera 28 & Edge

enter image description here

What it looks like in IE 10/11 enter image description here

So my problem is that i'm trying to achieve in IE the same behaviour as i have in Chrome and Firefox.

My SASS/SCSS

ul.images {
  float: left;
  clear: both;
  width: 100%;
  min-height: auto; // Required for Firefox
  padding: 0;
  margin: 0;
  border: 1px solid yellow;

  display: -webkit-flex;
  -webkit-flex-direction: row;

  display: -ms-flexbox;
  -ms-flex-direction: row;

  display: flex;
  flex-direction: row;

  li {
    border: 2px solid green;
    flex: 1 1 auto;
    width: auto;
    min-width: 0; // Required by Firefox
    max-width: 100%;
    max-height: auto;

    img {
      float: left; // Removes phantom margin
      width: auto;
      max-width: 100%;
      height: auto;
      max-height: 100px;
    }
  }
}

Here is a CodePen for anyone wanting a more detailed look.

like image 354
Matt Avatar asked Sep 14 '15 13:09

Matt


People also ask

Does flexbox work in ie11?

Note also that Internet Explorer 11 supports the modern display: flex specification however it has a number of bugs in the implementation.

Which flex property will use to prevent child element to flow out of parent width?

To override this behavior, use min-width: 0 or overflow: hidden .

How do I make my flex item not stretch width?

By default, the child elements of a flexbox container will stretch vertically to fill the height of the container. This can be prevented by using the align-self property on the child element that you do not want to stretch. This Pen is owned by dev on CodePen.


1 Answers

Change the <img> width from auto to 100%

img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 100px;
}

It seems that's Chrome who doesn't respect standard

like image 166
romuleald Avatar answered Oct 23 '22 06:10

romuleald