IE 11:图像在 flexbox 中不能正确缩小
IE 11: Image doesn't scale down correctly within flexbox
我正在尝试使用 flexbox 将两张图片放在一列中。在这种情况下,div 容器的 width
小于图像的 width
。在 Chrome 中图像完全适合 div 容器,但在 IE 中不适合,我不知道为什么。
div.outer {
width: 400px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
div.inner {
width: 100%;
border: 1px solid red;
}
img {
width: 100%;
height: auto;
}
<div class="outer">
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
</div>
https://jsfiddle.net/Yifei/16cpckqk/
这是我在 IE 11 中得到的:
IE11 似乎对 flex-shrink
property 的初始值有些问题。如果将其设置为零(最初设置为 1),它应该可以工作:
div.outer {
width: 400px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
div.inner {
flex-shrink: 0;
width: 100%;
border: 1px solid red;
}
img {
width: 100%;
height: auto;
}
<div class="outer">
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
</div>
接受的解决方案破坏了我在 ie 中的粘性页脚。所以我用以下不令人满意的 "only for ie JS"... 解决了这个令人不安的问题。 px 值而不是 "height:auto" 对我有用。
if(fuBrowser =='ie'){
var img = $("#teaser img");
img.each(function() {
$( this ).css({height: $( this ).height()});
});
}
我正在尝试使用 flexbox 将两张图片放在一列中。在这种情况下,div 容器的 width
小于图像的 width
。在 Chrome 中图像完全适合 div 容器,但在 IE 中不适合,我不知道为什么。
div.outer {
width: 400px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
div.inner {
width: 100%;
border: 1px solid red;
}
img {
width: 100%;
height: auto;
}
<div class="outer">
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
</div>
https://jsfiddle.net/Yifei/16cpckqk/
这是我在 IE 11 中得到的:
IE11 似乎对 flex-shrink
property 的初始值有些问题。如果将其设置为零(最初设置为 1),它应该可以工作:
div.outer {
width: 400px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
div.inner {
flex-shrink: 0;
width: 100%;
border: 1px solid red;
}
img {
width: 100%;
height: auto;
}
<div class="outer">
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
<div class="inner">
<img src="http://placehold.it/480x360">
</div>
</div>
接受的解决方案破坏了我在 ie 中的粘性页脚。所以我用以下不令人满意的 "only for ie JS"... 解决了这个令人不安的问题。 px 值而不是 "height:auto" 对我有用。
if(fuBrowser =='ie'){
var img = $("#teaser img");
img.each(function() {
$( this ).css({height: $( this ).height()});
});
}