简体   繁体   中英

Safari ignore height auto in img in mobile devices

I have a website developed with HTML, CSS (Bootstrap), JS and PHP. The problem came with the images in Safari. My img tag has a class img-fluid which has this to it's CSS:

max-width: 100%;
height: auto;

All works fine in all devices, except in Safari.

This is how it looks in Safari:

在此处输入图像描述

And this is how it is supposed to look like:

在此处输入图像描述

This happens to all the images in the web.

I have this meta tag:

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

I think the problem is that Safari ignores the height: auto; and all the images shrink to 100% of the container height, or something like that.

The problem was with the display of the parent container. I change de display: flex to display: block in the parent div ( div which contains the img tag) and the images start to working fine.

Thanks Problem Child for give me the right way:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM