我想每行显示3张图片。但代码显示第一行有2(2)个图像,然后它显示下一行3个图像。代码问题在哪里?
<table style="width: 99%;padding-top:30px;" dir="ltr" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
{foreach from=$execommittee item=v name=cat}
{if $smarty.foreach.cat.iteration % 3 == 0 && $smarty.foreach.cat.iteration > 0}
</tr>
<tr>
{/if}
<td width="142">
<p style="text-align: center;" align="justify">
<img src="themes/{$themes}/resources/images/publications/{$v.efilename}" border="0" width="142" height="152" /></a></p>
<p style="text-align: center;" align="justify">{$v.ename}</p>
</td>
{/foreach}
</tr>
</tbody>
</table>
答案 0 :(得分:3)
<table style="width: 99%;padding-top:30px;" dir="ltr" border="0" cellspacing="0" cellpadding="0">
<tbody>
{foreach from=$execommittee item=v name=cat}
<tr>
{if $smarty.foreach.cat.iteration % 3 == 0 && $smarty.foreach.cat.iteration > 0}
</tr>
<tr>
{/if}
<td width="142">
<p style="text-align: center;" align="justify">
<img src="themes/{$themes}/resources/images/publications/{$v.efilename}" border="0" width="142" height="152" /></a></p>
<p style="text-align: center;" align="justify">{$v.ename}</p>
</td>
</tr>
{/foreach}
</tbody>
</table>
你的tr标签应该在你的循环中。我不确定如果声明,我认为不需要。