gpt4 book ai didi

css - IE CSS 错误 : IMG original height affecting parent height

转载 作者:技术小花猫 更新时间:2023-10-29 11:42:08 25 4
gpt4 key购买 nike

我有一个 PARENT flexbox div(它也是列 flexbox 的一部分):

div.flex_block {
width:100%;
flex: 1 1 auto;
display:flex;
flex-direction:row;
align-items:center;
justify-content:space-between;
padding-bottom:30px;
}

它包含 2 个 child :

.flex_block  .content{
max-width:none; /* override other code */
flex: 0 1 50%;
}

.flex_block .image{
max-width:none; /* override other code */
flex: 0 1 35%;
}

第一个 child 里面有一些文字。第二个有一个超大图像,设置为 100% 宽度,所以它缩小到它的容器。

.flex_block  .image img{
display:block;
width:100%;
height: auto;
}

它在 Chrome 中按预期工作,但在 IE 中,原始 img 的高度似乎扩展了 PARENT 容器(即使它确实缩小以适合其容器)。如果我设置 img 高度,问题就解决了。 AUTO 不修复它。显然,我需要将其作为响应式设计,因此我不想以像素为单位设置高度。

下面是所发生情况的可视化: enter image description here

我也尝试过使用具有百分比宽度的内联元素而不是 flexbox,但问题仍然存在。

最佳答案

添加到容器的可能解决方案:

flex-shrink: 0;

或更具体到 IE11:

-ms-flex-negative: 0;

这似乎解决了我的问题,但您的结果可能会有所不同。

我并不假装理解它的原因,但它似乎对我有用。 :)

关于css - IE CSS 错误 : IMG original height affecting parent height,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33351298/

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