gpt4 book ai didi

javascript - 使用 CSS 或 jQuery 保持图像的纵横比?

转载 作者:太空狗 更新时间:2023-10-29 12:32:51 25 4
gpt4 key购买 nike

我有尺寸为 (900x512) 的图像。因为我要让它响应,所以图像需要在保持宽高比的屏幕宽度内进行调整!!

最佳答案

使用:

<img src="..." style="width: 100%; height: auto;" />

这将保持纵横比。 height: auto 将确保 height 未在其他地方设置(如 cale_b 所述)

关于javascript - 使用 CSS 或 jQuery 保持图像的纵横比?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33945388/

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