我使用的引导与Django和希望.item-container.col-MD-4是一个行内的三盒。 它应该是这个样子:
<div class="row">
<div class="item-container col-md-4> Stuff</div>
<div class="item-container col-md-4> Another Thing</div>
<div class="item-container col-md-4> This Next One</div>
</div>
我得到更多的东西是这样的:
<div class="row">
<div class="item-container col-md-4> Stuff
<div class="item-container col-md-4> Another Thing</div>
</div>
</div>
<div class="item-container col-md-4> This Next One</div>
这里是我的代码:
{% for product in products %}
{% if forloop.first %}
<div class="row">
{% endif %}
<div class="item-container col-md-4">
{{ product.someinfo }}
</div>
{% if forloop.counter != products|length %}
</div>
<script> console.log('not last', {{ products|length }}, {{forloop.counter}} ); </script>
{% endif %}
{% if forloop.last %}
</div>
<script> console.log('by 3', {{ products|length }}, {{forloop.counter}} );</script>
{% elif forloop.counter|divisibleby:3 %}
<script> console.log('last', {{ products|length }}, {{forloop.counter}} );</script>
<div class='row'>
{% endif %}
{% empty %}
<div class="nothing-found">
Nothing found.
</div>
{% endfor %}