动态生成N个轮播,每个轮播包含1张或更多图片。我想以一种整洁的方式以网格格式显示它们。现在,它以水平格式显示。
当前形成方式:
我正在使用Bootstrap4。有什么方法可以实现我想要的?
使用jinja模板的现有代码:
{% for track_id, image_path in image_urls.items %}
<div>
<div id="nCarousel" class="carousel slide" data-ride="carousel" data-interval="500">
<div class="carousel-inner">
{% for ip in image_path %}
<!-- <h1> Index: {{ forloop.counter }}</h1> -->
{% if forloop.counter == 1 %}
<div class="carousel-item active">
<img class="d-block w-100" src="{{ ip }}" >
</div>
{% endif %}
<div class="carousel-item">
<img class="d-block w-100" src="{{ ip }}" >
</div>
{{ forloop.length }}
{% endfor %}
</div>
<a class="carousel-control-prev" href="#nCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#nCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
{% endfor %}
<style> .carousel {
width:180px;
height:180px;
}</style>