【发布时间】:2021-10-12 14:23:47
【问题描述】:
我有一个包含 1,2 或三个图像的容器(取决于一些未知的东西)。
如果有多个图像,那么它们都应该能够并排放入容器中。
我试过设置
.image-wrapper {
display:flex;
height: 50%;
flex-grow: 1;
}
.image-wrapper img{
width: auto;
max-height: 100%;
flex-grow: 1;
}
并认为flex-grow:1 应该做到这一点,但这并不完全奏效。
<div class="image-wrapper">
{% if p.does_exist %}
<a href="{{p.link}}" target="_blank" rel="noopener">
<img src="{{p.image_url}}" alt="image of product produkt" />
</a>
{% else %}
<a href="{{p.link}}" target="_blank" rel="noopener">
<img src="{{p.image_url}}" alt="Image off produkt" />
<img src="{% static 'media/discount.png' %}" alt="Discount tag" />
</a>
{% endif %}
</div>
【问题讨论】:
-
这能回答你的问题吗? Flexbox not giving equal width to elements