【发布时间】:2023-03-15 17:29:01
【问题描述】:
我有以下代码用于在我的页面中显示图像(在 class="floating-box" 内):
<img style="display: block; margin: 0 auto; max-width: 100%; max-height: 100%; width: auto; height: auto;" ng-src="{{product.image}}"/>
.floating-box {
display: inline-block;
width: 300px;
height: 450px;
margin: 10px;
vertical-align: top;
}
问题是我没有看到所有图像的统一尺寸。较小的图像不会拉伸。知道发生了什么吗?
谢谢。
【问题讨论】:
-
width: auto%看起来不对。 -
… 和
auto并不意味着拉伸。 -
我认为自动意味着必要时拉伸? @昆汀
-
auto通常是 CSS 默认值。添加它只是不必要的膨胀标记。 -
@Ahsan,你检查答案了吗?