0

私は何かをしようとしていますが、できません。結果が次のようなテーブルがあります。

+----------+
|Dressing 1|
+----------+
|Dressing 2|
+----------+
|Dressing 3|
+----------+
|Dressing 4|
+----------+
|Dressing 5|
+----------+
|Dressing 6|
+----------+
|Dressing 7|
+----------+
|Dressing 8|
+----------+
|Dressing 9|
+----------+

しかし、私はそれを次のように表示したいと思います:

+----------+----------+----------+
|Dressing 1|Dressing 2|Dressing 3|
+----------+----------+----------+
|Dressing 4|Dressing 5|Dressing 6|
+----------+----------+----------+
|Dressing 7|Dressing 8|Dressing 9|
+----------+----------+----------+

今、私はこのようなコードを持っています:

<table cellpadding="6" border=0>

<tr style="height:20px">

{foreach from=$group.attributes name=awp_loop item=group_attribute}

{strip}

{assign var='id_attribute' value=$group_attribute.0}

<td align="center" {if $group.group_layout}valign="top"{/if}>
<div id="awp_checkbox_cell{$id_attribute}" style="{if !$group.group_layout}float:left;{else}width:100%;clear:left;{/if}">

{if $group.group_per_row > 1}<center>{/if}

<input style="border:none;margin:0;padding:0" type="checkbox" {if $group.attributes_quantity.$id_attribute == 0 && $awp_out_of_stock == 'disable'}disabled="disabled"{/if} class="awp_attribute_selected awp_group_class_{$group.id_group}" name="awp_group_{$group.id_group}" id="awp_checkbox_group_{$id_attribute}" onclick="awp_select('{$group.id_group|intval}',{$group_attribute.0|intval}, {$awp_currency.id_currency},false);" value="{$group_attribute.0|intval}" {if $group.default|is_array && $id_attribute|in_array:$group.default}checked{/if} />&nbsp;

{if $group.group_per_row > 1}</center>{/if}

</div>
</td>

{if $smarty.foreach.awp_loop.iteration < $group.attributes|@count && $smarty.foreach.awp_loop.iteration % $group.group_per_row == 0}

</tr>

<tr style="height:20px;">

{/if}

{/strip}

{/foreach}

</tr>

</table>

しかし、テーブルを作成する方法や、連続して3つのエントリのみを作成するコードを理解することはできません。誰かが助けることができれば、それは素晴らしいことです。

4

1 に答える 1

2

liリストを使用して、各要素を左にフロートさせます。それはあなたにあなたの望ましい結果を与えるでしょう、そしてそれはずっときれいになるでしょう。

http://jsfiddle.net/Zppya/

テーブルメソッドについては...カウンターを追加し、mod / restore関数を使用して、3つおきの要素を決定し、新しい行を作成できるようにします。

于 2012-11-28T19:24:56.943 に答える