Reputation: 4008
I have the code below.
I want to force an image max-width
to be constrained/rescale to the container width , and height is free. It works in Chrome/Firefox but not in IE11
.cimage {
-ms-flex-align: center;
align-items: center;
border: 1px solid red;
display: -ms-flexbox;
display: flex;
-ms-flex-negative: 0;
flex-shrink: 0;
-ms-flex-positive: 0;
flex-grow: 0;
-ms-flex-pack: center;
justify-content: center;
padding: .75rem;
width: 5.5rem;
}
.cimage img {
max-width: 100%;
min-width:1px;
}
<div class="cimage">
<a href="/">
<img src="https://via.placeholder.com/250x150">
</a>
</div>
IE screenshot:
Upvotes: 1
Views: 41
Reputation: 42352
Add flex: 1
or min-width: 1px
to flex item - the a
element, to fix this in IE11 as well. See demo below:
.cimage {
-ms-flex-align: center;
align-items: center;
border: 1px solid red;
display: -ms-flexbox;
display: flex;
-ms-flex-negative: 0;
flex-shrink: 0;
-ms-flex-positive: 0;
flex-grow: 0;
-ms-flex-pack: center;
justify-content: center;
padding: .75rem;
width: 5.5rem;
}
.cimage img {
max-width: 100%;
min-width:1px;
}
.cimage a { /* ADDED */
flex: 1;
}
<div class="cimage">
<a href="/">
<img src="https://via.placeholder.com/250x150">
</a>
</div>
Upvotes: 1