gpt4 book ai didi

css - 当子图像在 IE 中垂直收缩时,Flex 元素不会垂直收缩

转载 作者:行者123 更新时间:2023-11-28 15:20:32 25 4
gpt4 key购买 nike

我再次意识到这个问题已经被问过几次了,但无论我找到什么答案,它实际上都没有任何作用。

我正在尝试做 Chrome 和任何其他受人尊敬的浏览器所做的事情:

Chrome rendering of the flexbox

但是在 IE11 中,我得到了这个:

IE version

.inner-image img {
border-radius: 50%;
max-width: 100%;
// http://jsfiddle.net/qgybon8q/2/
flex-shrink: 0;

// http://jsfiddle.net/mftnbk38/4/
//flex: 0 0 auto;
//object-fit: scale-down;

// https://connect.microsoft.com/IE/feedback/details/1218984/ie11-display-flex-issue
//flex: 1;

//
//max-width: calc( 100% - 0.1px );
}

fiddle 可以在这里找到:https://jsfiddle.net/Kikketer/e9jb5pvh/

我尝试过的所有尝试都以失败告终。事实上,即使运行其他解决方案的 fiddle ,它似乎也不起作用。

有什么我想念的吗?

最佳答案

也许您错过了 Microsoft 文档中的这篇文章:

来自文章:

If anyone arrives here trying to fix this maddening issue in IE11 - I suggest adding a min-height: 1px to the flex wrapper of your image to force IE to recalculate the size based on an image that has height: auto applied to it. This solved the issue and had no impact on other browsers, so I didn't need to target IE11 specifically.

因此,将 min-height: 1px 添加到 .body 中:

revised fiddle

.wrapper {
display: flex;
flex-direction: column;
border: 1px solid black;
width: 400px;
}

.head {
background-color: rgba(200, 100, 100, 1);
}

.body {
min-height: 1px; /* NEW (for IE11) */
background-color: rgba(200, 200, 200, 1);
}

.inner {
display: flex;
flex-direction: row;
}

.inner-content {
flex: 1 1 75%;
}

.inner-image {
flex: 1 1 25%;
}

.inner-image img {
border-radius: 50%;
max-width: 100%;
flex-shrink: 0;
}

.foot {
background-color: rgba(100, 200, 100, 1);
}
<div class="wrapper">
<div class="head">
<p>Header content</p>
</div>
<div class="body">
<div class="inner">
<div class="inner-content">
<p>The image to the right is normally 253px high/wide</p>
</div>
<div class="inner-image">
<img src="http://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg">
</div>
</div>
</div>
<div class="foot">
<p>Footer Content</p>
</div>
</div>

关于css - 当子图像在 IE 中垂直收缩时,Flex 元素不会垂直收缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46247556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com