左文右图左图右文的文章如何循环
代码如下:
<li class="clear">
<div class="case-list left fl">
<a href="javascript:;" class="white">
<div class="top">
<div class="num en">1</div>
<div class="line"><img src="/templets/moban/static/picture/line_03.png"></div>
</div>
<div class="mid">
<div class="mid-1 en">Order the weekly flower<br>to please yourself</div>
<div class="mid-2 en big">花点时间</div>
</div>
<div class="white-bot">
<div class="bot-1"></div>
<div class="bot-2">中国首个“无用生活美学”电商平台</div>
</div>
</a>
</div>
<a href="javascript:;" class="right fr"><img src="/templets/moban/static/picture/20171129100227804.jpg"></a>
</li>
<li class="clear">
<a href="javascript:;" class="right fl"><img src="/templets/moban/static/picture/20171029065517193.jpg"></a>
<div class="case-list left fr">
<a href="javascript:;" class="white">
<div class="top">
<div class="num en">2</div>
<div class="line"><img src="/templets/moban/static/picture/line_03.png"></div>
</div>
<div class="mid">
<div class="mid-1 en">The art of audio</div>
<div class="mid-2 en big">FIIL</div>
</div>
<div class="white-bot">
<div class="bot-1"></div>
<div class="bot-2">定义无线主义耳机新形态</div>
</div>
</a>
</div>
</li>
<div class="case-list left fl">
<a href="javascript:;" class="white">
<div class="top">
<div class="num en">1</div>
<div class="line"><img src="/templets/moban/static/picture/line_03.png"></div>
</div>
<div class="mid">
<div class="mid-1 en">Order the weekly flower<br>to please yourself</div>
<div class="mid-2 en big">花点时间</div>
</div>
<div class="white-bot">
<div class="bot-1"></div>
<div class="bot-2">中国首个“无用生活美学”电商平台</div>
</div>
</a>
</div>
<a href="javascript:;" class="right fr"><img src="/templets/moban/static/picture/20171129100227804.jpg"></a>
</li>
<li class="clear">
<a href="javascript:;" class="right fl"><img src="/templets/moban/static/picture/20171029065517193.jpg"></a>
<div class="case-list left fr">
<a href="javascript:;" class="white">
<div class="top">
<div class="num en">2</div>
<div class="line"><img src="/templets/moban/static/picture/line_03.png"></div>
</div>
<div class="mid">
<div class="mid-1 en">The art of audio</div>
<div class="mid-2 en big">FIIL</div>
</div>
<div class="white-bot">
<div class="bot-1"></div>
<div class="bot-2">定义无线主义耳机新形态</div>
</div>
</a>
</div>
</li>
代码截图如下:
我们分析一下代码结构,第一个li代码里面,左边文字的样式是fl,右边图片的样式是fr。第二个li代码里面,左边图片的样式是fl,右边文字的样式是fr。
从这里我们可以看出,fl是左浮动的样式,fr是右浮动的样式,所以我们只要判断当前循环是奇数,就输出左文右图,当前循环是偶数就输出左图右文。
循环代码如下:
{dede:arclist typeid='7' channelid='17' addfields='enname,jianjie' isweight='Y' orderby='weight' orderway='asc' }
<li class="clear">
<div class="case-list left [field:global name=autoindex runphp='yes']if(@me%2==1)@me='fl';else @me='fr';[/field:global]">
<a href="javascript:;" class="white">
<div class="top">
<div class="num en">[field:global name=autoindex runphp="yes"]@me;[/field:global]</div>
<div class="line"><img src="/templets/moban/static/picture/line_03.png"></div>
</div>
<div class="mid">
<div class="mid-1 en">[field:enname/]</div>
<div class="mid-2 en big">[field:title/]</div>
</div>
<div class="white-bot">
<div class="bot-1"></div>
<div class="bot-2">[field:jianjie/]</div>
</div>
</a>
</div>
<a href="javascript:;" class="right [field:global name=autoindex runphp='yes']if(@me%2==1)@me='fr';else @me='fl';[/field:global]"><img src="[field:picname/]"></a>
</li>
{/dede:arclist}
<li class="clear">
<div class="case-list left [field:global name=autoindex runphp='yes']if(@me%2==1)@me='fl';else @me='fr';[/field:global]">
<a href="javascript:;" class="white">
<div class="top">
<div class="num en">[field:global name=autoindex runphp="yes"]@me;[/field:global]</div>
<div class="line"><img src="/templets/moban/static/picture/line_03.png"></div>
</div>
<div class="mid">
<div class="mid-1 en">[field:enname/]</div>
<div class="mid-2 en big">[field:title/]</div>
</div>
<div class="white-bot">
<div class="bot-1"></div>
<div class="bot-2">[field:jianjie/]</div>
</div>
</a>
</div>
<a href="javascript:;" class="right [field:global name=autoindex runphp='yes']if(@me%2==1)@me='fr';else @me='fl';[/field:global]"><img src="[field:picname/]"></a>
</li>
{/dede:arclist}