我正在尝试设置一个循环以在我的索引页面上显示帖子,以便它们适合 skeleton.css 框架。第一个帖子应该占据十二列,并包含在它自己的行中。此后每两个帖子应单独包装在一行中。我正在使用以下内容:
{% elsif forloop.index | modulo: 2 == 0 %}
Run Code Online (Sandbox Code Playgroud)
...试图在每两个帖子周围创建一个行 div。这似乎不起作用,因为在输出中,每个单独的帖子都包含在一行 div 中。
<div class="posts">
{% for post in site.posts %}
{% if forloop.first == true %}
<div class="row">
<article class="twelve columns"></article>
</div>
{% elsif forloop.index | modulo:2 == 0 %}
<div class="row">
<article class="six columns"></article>
</div>
{% else %}
<article class="six columns"></article>
{% endif %}
{% endfor %}
</div>
Run Code Online (Sandbox Code Playgroud)