【问题标题】:Chrome v75 : Images with max-width stretched inside a flex column divChrome v75:在 flex 列 div 内拉伸最大宽度的图像
【发布时间】:2019-10-24 18:40:18
【问题描述】:

自从较新的 Chrome 版本 (75.0.3770.80) 以来,我网站上的图片很少被拉伸。

这些图像在一个 div 中,具有这些属性:

<div class="column">
    <img
        :src="insuranceLogo"
        class="insurance"
    >
    <span>
        {{ offer.offer_name }}
    </span>
</div>

.column {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.insurance {
    width: 100%;
    max-width: 150px;
}

直到今天,它运行良好,但在新的 Chrome 版本中,我的图像都被拉伸了!

我在旧版 Chrome 上尝试过,没问题,所以我将其更新为新版本:结果相同,延长了。

我的解决方案是将我的 img 标签包装在一个 div 中。但我很想知道为什么这种行为会改变。

谢谢! :)

【问题讨论】:

    标签: html css google-chrome flexbox


    【解决方案1】:

    我知道这并不能回答您的主要问题:“为什么这种行为会改变?”。

    只是发布另一个可能的解决方案。为图像元素设置flex-basis: 0; 对我有用。

    .insurance {
        width: 100%;
        max-width: 150px;
        flex-basis: 0;
    }
    

    【讨论】:

    • 很好的修复!我会试试看:)
    【解决方案2】:
    猜你喜欢
    • 2012-04-04
    • 2015-06-04
    • 2014-08-22
    • 1970-01-01
    • 2018-06-28
    • 1970-01-01
    • 1970-01-01
    • 2014-01-22
    • 2013-05-06
    相关资源
    最近更新 更多