gpt4 book ai didi

html - iOS中的Flex图像,使图像宽度均匀

转载 作者:搜寻专家 更新时间:2023-10-31 08:22:56 24 4
gpt4 key购买 nike

我如何在 iOS 中实现这一点?在 firefox 中它可以工作,但找不到适用于 iPad 的解决方案。

<style>
#products {
display: flex;
}
#products img {
width: auto !important;
height: auto !important;
}
</style>

<div id="products">
<img src="https://nomadweb.design/img/imac-frame-ilioslighting.jpg" width="980" height="815" />
<img src="https://nomadweb.design/img/phone-frame-ilioslighting.jpg" width="406" height="815" />
<img src="https://nomadweb.design/img/imac-frame-mallachandcompany.jpg" width="980" height="815" />
<img src="https://nomadweb.design/img/phone-frame-mallachandcompany.jpg" width="406" height="815" />
<img src="https://nomadweb.design/img/imac-frame-bighousesound.jpg" width="980" height="815" />
<img src="https://nomadweb.design/img/phone-frame-bighousesound.jpg" width="406" height="815" />
</div>

这是它在 Firefox 中的样子 enter image description here如何在 iOS 中执行此操作?

这是它在 firefox 中的响应方式,希望在 iOS 中实现相同的效果。

最佳答案

方法 1:确保在标记中设置图像的固有尺寸(自然大小),以保持纵横比。

#products {
display: flex;
}

#products img {
min-width: 0;
max-width: 100%;
height: 100%;
}
<div id="products">
<img src="https://i.imgur.com/5fhlNOd.jpg" width="980" height="815">
<img src="https://i.imgur.com/SLZv3Yu.jpg" width="406" height="815">
<img src="https://i.imgur.com/eQ6LawW.jpg" width="980" height="815">
<img src="https://i.imgur.com/0W3B4ce.jpg" width="406" height="815">
<img src="https://i.imgur.com/7jGyI95.jpg" width="980" height="815">
<img src="https://i.imgur.com/oFhKzAZ.jpg" width="406" height="815">
</div>

方法 2:为每个图像添加一个包装器,尺寸是可选的。

#products {
display: flex;
}

#products img {
width: 100%;
height: auto;
}
<div id="products">
<div><img src="https://i.imgur.com/5fhlNOd.jpg"></div>
<div><img src="https://i.imgur.com/SLZv3Yu.jpg"></div>
<div><img src="https://i.imgur.com/eQ6LawW.jpg"></div>
<div><img src="https://i.imgur.com/0W3B4ce.jpg"></div>
<div><img src="https://i.imgur.com/7jGyI95.jpg"></div>
<div><img src="https://i.imgur.com/oFhKzAZ.jpg"></div>
</div>

关于html - iOS中的Flex图像,使图像宽度均匀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54527746/

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