python - 对齐 Bootstrap 'Thumbnail Grid System'

标签 python html css jinja2

我正在尝试将所有图像均等地对齐,我附上了当前外观的屏幕录像。我不确定为什么要这样做,因为我使用的是 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 转到下一行。您有两个选择:

  1. 使用计数器在该行的每个第一个 div 之前添加一个,并在第四个之后添加一个结束 div。

  2. 使用 matchHeight.js 使该行的每个 div 具有相同的高度。

关于python - 对齐 Bootstrap 'Thumbnail Grid System',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40833156/

相关文章:

javascript - 如何使文档端脚本有条件?

python - pandas 数据帧上的 s3fs gzip 压缩

python - Flask python蓝图逻辑代码分离

html - 如何在页面末尾修复页脚?

html - 为什么 chrome 停止打开 bxslider div 中嵌入的 <a href 超链接

javascript - 在 JQGrid 中创建复杂的标题布局并在单元格中设置颜色

python - 测试 python 的线程

python - 当输出保存在变量中时,为什么 .read() 命令会执行不同的操作

html - 为什么将我的 div 变成一个圆圈会影响 bootstrap 列?

javascript - 使用 JavaScript/jQuery 永久覆盖 CSS