首先找到默認(rèn)模板中的循環(huán)代碼:
{php $j=1;}
{loop subcat($catid) $v}
{php if($v['type']!=0) continue;}
<div class="box cat-area" {if $j%2==1}style="margin-right:10px"{/if}>
.....
{if $j%2==0}<div class="bk10"></div>{/if}
{$j++}
{/loop}
現(xiàn)在假如我要改成一行3個(gè),那么新的代碼就是:
{php $j=1;}
{loop subcat($catid) $v}
{php if($v['type']!=0) continue;}
<div class="box cat-area" {if $j%3==1}style="margin-right:10px"{/if}{if $j%3==2}style="margin-right:10px"{/if}>
.......
{if $j%3==0}<div class="bk10"></div>{/if}
{$j++}
{/loop}
下面做出解釋:
①第4行代碼:“$j%3==1”代表每行3個(gè)box(每個(gè)欄目的邊框css樣式)的第一個(gè),“$j%3==2”就是3個(gè)box中間的一個(gè),這兩個(gè)box都使用了style樣式 margin-right:10px的樣式,即右外邊距10px;
②第6行代碼:這個(gè)是每行與每行的邊距代碼;
③修改default_blue.css樣式表里的box、cat-area,修改邊框的寬度及顏色等自定義樣式。