bootstrap 4 img-fluid does not change image height

亡梦爱人 提交于 2019-12-04 01:23:50

The problem was I wrapped image in div with class .row which have display property set to flex. once removed this class from parent div image working as expected

bwk

Actually height:auto did not work for me, but height:100% worked like a champ.

Try wrapping your image in a figure element.

<div class="col-sm-6">
    <figure>
        <img class="img-fluid" src="/assets/blogs/14853991244821.jpg" alt="">
    </figure>
</div>

My magic hax

<style>
    figure {
        margin: 16px 40px !important; 
    }
    .img-fluid {
      max-width: 100%;
      height: auto;
    }
</style>
<div class="row align-items-center">
    <div class="col-lg-2">
       <figure>
           <img class="img-fluid" src="path-image.png" />
       </figure
    </div>
</div>

If you set the css height property to auto then the height will also be fluid when resizing.

just logged in to share this super quick, and hopefully minimal changing fix

in you style, simply set min-height to 1px or 1rem

<head>
    ...
    <style>
    .ieFix
    {
        min-height:1px;
    }
    </style>
</head>
<body>
<div class="card text-center">
    <img src="..." class="card-img-top ieFix" alt="...">
        <div class="card-body">
            <h5 class="card-title">...</h5>
            <p class="card-text">...</p>
            <p class="card-text post-meta"...</p>
        </div>
</div>
</body>

Have confirmed this works and nothing changes on Chrome in mobile phone and tablet screens.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!