Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flexbox on IE11: image stretched for no reason?

I'm having an issue with flexbox on IE11 and while I'm aware there's lots of known issue, I haven't been able to find a solution...

<div class="latest-posts">     <article class="post-grid">         <img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />         <div class="article-content">              <h2>THIS IS POST TITLE</h2>              <p>BLAH</p>         </div>     </article> </div> 

And the CSS...

img {   max-width: 100%; }  .latest-posts {   margin: 30px auto; }  article.post-grid {   width: 375px;   float: left;   margin: 0 25px 100px 0;   padding-bottom: 20px;   background-color: #fff;   border: 1px solid #f3f3f3;   border-radius: 2px;   font-size: 14px;   line-height: 26px;   display: flex;   flex: 1 0 auto;   flex-direction: column;   justify-content: flex-start;   align-content: flex-start; } .article-content {   padding: 20px 35px; } 

Images are getting stretched within a flex container.

enter image description here

Applying align-items: flex-start (I figured, since "stretched" is the default value...) or justify-content: flex-start doesn't seem to work.

Codepen: example of what I mean

What am I doing wrong?

like image 525
Jusi Avatar asked Apr 24 '16 11:04

Jusi


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.

Why is there additional space in the Flexbox container?

It's because your container is full width and the children are only 100px. The rest space is added to the layout. What would you like to achieve?


1 Answers

to avoid this funny behavior, you may reset the flex-shrink property.

This looks like a bug, despite what Microsoft says:

<'flex-shrink'>

Sets the flex shrink factor or negative flexibility for the flex item. The flex shrink factor determines how much a flex item will shrink relative to the other items in the flex container.

If omitted, the element's negative flexibility is "0". A negative value is not valid.

Source: https://msdn.microsoft.com/en-us/library/jj127297%28v=vs.85%29.aspx https://msdn.microsoft.com/en-us//library/hh772069%28v=vs.85%29.aspx

img {       max-width: 100%;       flex-shrink: 0;     } 

img {    max-width: 100%;    flex-shrink: 0;  }    .latest-posts {    margin: 30px auto;  }    article.post-grid {    width: 375px;    float: left;    margin: 0 25px 100px 0;    padding-bottom: 20px;    background-color: #fff;    border: 1px solid #f3f3f3;    border-radius: 2px;    font-size: 14px;    line-height: 26px;    display: flex;    flex: 1 0 auto;    flex-direction: column;    justify-content: flex-start;    align-content: flex-start;  }  article.post-grid .article-content {    padding: 20px 35px;  }
<div class="latest-posts">    <article class="post-grid">      <img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />      <div class="article-content">        <h2>THIS IS POST TITLE</h2>        <p>Society excited by cottage private an it esteems. Fully begin on by wound an. Girl rich in do up or both. At declared in as rejoiced of together.</p>      </div>    </article>    <article class="post-grid">      <img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />      <div class="article-content">        <h2>MUCH LONGER POST TITLE TO ILLUSTRATE HEIGHTS</h2>        <p>Recommend new contented intention improving bed performed age.</p>      </div>    </article>    <article class="post-grid">      <img src="http://lorempixel.com/image_output/cats-q-c-640-480-4.jpg" alt="" />      <div class="article-content">        <h2>SHORT TITLE</h2>        <p>Merry alone do it burst me songs. Sorry equal charm joy her those folly ham. In they no is many both. Recommend new contented intention improving bed performed age. Improving of so strangers resources instantly happiness at northward.</p>      </div>    </article>  </div>

http://codepen.io/anon/pen/KzBOvq

like image 200
G-Cyrillus Avatar answered Oct 29 '22 15:10

G-Cyrillus