我正在尝试将所有图像均等地对齐,我附上了当前外观的屏幕录像。我不确定为什么要这样做,因为我使用的是 Boostraps 列设计 (class="col-sm-4 col-md-3"
),所以它们的大小都相同......
Here可以查看录屏
编辑:
这是我当前的代码:
{% extends 'navbar.html' %}
{% block container %}
<div class="row">
{% for product in my_list %}
<div class="col-sm-4">
<div class="thumbnail">
<img src="{{ product[4] }}" alt="{{ product[1] }}">
<div class="caption">
<h3>{{ product[1] }}</h3>
<p>This is a test, this will have the price and category of the product</p>
<p><a href="#" class="btn btn-primary" role="button">View Product</a></p>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
最佳答案
这是因为有些图像比其他图像大,使得每个 div 的高度不同,这使得下一个图像 div 转到下一行。您有两个选择:
使用计数器在该行的每个第一个 div 之前添加一个,并在第四个之后添加一个结束 div。
使用 matchHeight.js 使该行的每个 div 具有相同的高度。
关于python - 对齐 Bootstrap 'Thumbnail Grid System',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40833156/