gpt4 book ai didi

css - 强制 css 以比例纵横比显示图像

转载 作者:行者123 更新时间:2023-11-28 10:58:01 24 4
gpt4 key购买 nike

imax 是一个 div 元素。

#imax {
width:222px;
height:222px;
}
#imax img {
width:222px;
height:auto;
}

如果我尝试在宽度或高度上自动设置任何一种方式,则具有不同方向的图像将导致任一比例的扭曲。如何修复以比例纵横比显示?

最佳答案

省略高度:

#imax img {
width:222px;
}

浏览器将负责宽高比的计算。

关于css - 强制 css 以比例纵横比显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3076158/

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