OMGDrAcula OMGDrAcula - 1 month ago 35
CSS Question

Flexbox layout breaking in IE 11. Prefixes not working?

I have a material card layout that I am using Flexbox for and it works fine in Chrome/FF/Safari.

I have used Flexbox before with success back to IE10 by just using autoprefixer, but for some reason how I have this just breaks in IE11.

My layout goals are to have the cards like in the pen that are all equal height even if the content of the card below the image is longer than other cards. Though we have a soft limit in mind as far as amount of characters.

You can see in this codepen: http://codepen.io/OMGDrAcula/pen/vXAqAR



.flex-row {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6, BB7 */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
display: flex; /* NEW, Spec - Firefox, Chrome, Opera */

-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
.flex-column {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.card {
padding-bottom: 80px;
position: relative;
}
.card-action {
position: absolute;
bottom: 0; left: 0;
width: 100%;
}


/* Your untouched stuff */
.card {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}

.card {
margin-top: 10px;
box-sizing: border-box;
border-radius: 2px;
background-clip: padding-box;
}
.card span.card-title {
color: #fff;
font-size: 24px;
font-weight: 300;
text-transform: uppercase;
}

.card .card-image {
position: relative;
overflow: hidden;
}
.card .card-image img {
border-radius: 2px 2px 0 0;
background-clip: padding-box;
position: relative;
z-index: -1;
}
.card .card-image span.card-title {
position: absolute;
bottom: 0;
left: 0;
padding: 16px;
}
.card .card-content {
padding: 16px;
border-radius: 0 0 2px 2px;
background-clip: padding-box;
box-sizing: border-box;
}
.card .card-content p {
margin: 0;
color: inherit;
}
.card .card-content span.card-title {
line-height: 48px;
}
.card .card-action {
border-top: 1px solid rgba(160, 160, 160, 0.2);
padding: 16px;
}
.card .card-action a {
color: #ffab40;
margin-right: 16px;
transition: color 0.3s ease;
text-transform: uppercase;
}
.card .card-action a:hover {
color: #ffd8a6;
text-decoration: none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row flex-row">
<!-- Card Projects -->
<div class="col-md-2 flex-column">
<div class="card">
<div class="card-image">
<img class="img-responsive" src="http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0Bx4BSt6jniD7TDlCYzRROE84YWM/materialdesign_introduction.png">
<span class="card-title">Material Cards</span>
</div>

<div class="card-content">
<p>Cards for display in portfolio style material design by Google. Cards for display in portfolio style material design by Google. Cards for display in portfolio style material design by Google.</p>
</div>

<div class="card-action">
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
</div>
</div>
</div>
<div class="col-md-2 flex-column">
<div class="card">
<div class="card-image">
<img class="img-responsive" src="http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0Bx4BSt6jniD7TDlCYzRROE84YWM/materialdesign_introduction.png">
<span class="card-title">Material Cards</span>
</div>

<div class="card-content">
<p>Cards for display in portfolio style material design by Google.</p>
</div>

<div class="card-action">
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
</div>
</div>
</div>
<div class="col-md-2 flex-column">
<div class="card">
<div class="card-image">
<img class="img-responsive" src="http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0Bx4BSt6jniD7TDlCYzRROE84YWM/materialdesign_introduction.png">
<span class="card-title">Material Cards</span>
</div>

<div class="card-content">
<p>Cards for display in portfolio style material design by Google.</p>
</div>

<div class="card-action">
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
</div>
</div>
</div>
<div class="col-md-2 flex-column">
<div class="card">
<div class="card-image">
<img class="img-responsive" src="http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0Bx4BSt6jniD7TDlCYzRROE84YWM/materialdesign_introduction.png">
<span class="card-title">Material Cards</span>
</div>

<div class="card-content">
<p>Cards for display in portfolio style material design by Google.</p>
</div>

<div class="card-action">
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
</div>
</div>
</div>
<div class="col-md-2 flex-column">
<div class="card">
<div class="card-image">
<img class="img-responsive" src="http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0Bx4BSt6jniD7TDlCYzRROE84YWM/materialdesign_introduction.png">
<span class="card-title">Material Cards</span>
</div>

<div class="card-content">
<p>Cards for display in portfolio style material design by Google.</p>
</div>

<div class="card-action">
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
</div>
</div>
</div>
<div class="col-md-2 flex-column">
<div class="card">
<div class="card-image">
<img class="img-responsive" src="http://material-design.storage.googleapis.com/publish/v_2/material_ext_publish/0Bx4BSt6jniD7TDlCYzRROE84YWM/materialdesign_introduction.png">
<span class="card-title">Material Cards</span>
</div>

<div class="card-content">
<p>Cards for display in portfolio style material design by Google.</p>
</div>

<div class="card-action">
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
<a href="#" target="new_blank">Link</a>
</div>
</div>
</div>
</div>
</div>




Answer

The problem isn't the prefixes. The problem is this rule in the Bootstrap CSS:

.carousel-inner > .item > a > img,
.carousel-inner > .item > img,
.img-responsive,
.thumbnail a > img,
.thumbnail > img {
    display: block;
    max-width: 100%;
    height: auto;
}

IE11 isn't recognizing the specified dimensions on the image (at least not in the way other browsers interpret it). This seems to be a known issue:

Basically, you need to control the height of the image. height: auto in IE 11 is allowing the image to max out in size. You could try using a fixed height (demo), nesting flex containers, or some other method that defines the height of the iamge.