-1

我在 Django 中创建了一个模型,我可以在管理站点中上传图片,稍后它将显示在主页中。

*.html 文件

<!-- templates/home.html -->
<h1>Django Image Uploading</h1>
<ul>
  {% for post in object_list %}
    <h2>{{ post.title }}</h2>
    <img src="{{ post.cover.url}}" alt="{{ post.title }}">
  {% endfor %}
</ul>

如何在行视图中显示所有图片?而不是列?(我想建立的图片库类型的页面)

4

1 回答 1

0

正如您提到 bootstrap-4 作为标签之一,这里是使用 bootstrap 的方法;

<div class="container">
  <div class="row"> <!-- all the divs placed inside this div will be placed in a row instead of column -->
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
    <div class="col-sm">
      One of three columns
    </div>
  </div>
</div>

with 类divs里面的所有东西都会水平排列成一排。divrow

更多请点击这里;https://getbootstrap.com/docs/5.0/layout/grid/#row-columns

于 2020-12-08T10:52:15.730 回答